__init__.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. from config import (
  2. BOT_TOKEN, API_ID, API_HASH, SUDO_USERS_ID, PHONE_NUMBER,
  3. LOG_GROUP_ID, FERNET_ENCRYPTION_KEY, MONGO_DB_URI,
  4. WELCOME_DELAY_KICK_SEC, ARQ_API_BASE_URL as ARQ_API,
  5. MAIN_CHATS
  6. )
  7. from pyrogram import Client
  8. from motor.motor_asyncio import AsyncIOMotorClient as MongoClient
  9. from Python_ARQ import ARQ
  10. import time
  11. import logging
  12. f = open("error.log", "w")
  13. f.write("PEAK OF LOG FILE")
  14. LOG_FORMAT = (
  15. '''
  16. [%(asctime)s.%(msecs)03d] %(filename)s:%(lineno)s
  17. %(levelname)s: %(message)s''')
  18. logging.basicConfig(
  19. level=logging.INFO,
  20. format=LOG_FORMAT,
  21. datefmt="%m-%d %H:%M",
  22. filename="error.log",
  23. filemode="w",
  24. )
  25. console = logging.StreamHandler()
  26. console.setLevel(logging.ERROR)
  27. formatter = logging.Formatter(LOG_FORMAT)
  28. console.setFormatter(formatter)
  29. logging.getLogger("").addHandler(console)
  30. log = logging.getLogger()
  31. SUDOERS = SUDO_USERS_ID
  32. def init_sudo():
  33. global SUDOERS
  34. from wbb.utils.botinfo import USERBOT_ID
  35. SUDOERS.append(USERBOT_ID)
  36. FERNET_ENCRYPTION_KEY = FERNET_ENCRYPTION_KEY
  37. WELCOME_DELAY_KICK_SEC = WELCOME_DELAY_KICK_SEC
  38. LOG_GROUP_ID = LOG_GROUP_ID
  39. MOD_LOAD = []
  40. MOD_NOLOAD = []
  41. bot_start_time = time.time()
  42. mongo_client = MongoClient(MONGO_DB_URI)
  43. db = mongo_client.wbb
  44. # Userbot client
  45. print("\nStarting Helper Userbot")
  46. app2 = Client(
  47. "userbot",
  48. phone_number=PHONE_NUMBER,
  49. api_id=API_ID,
  50. api_hash=API_HASH
  51. )
  52. # Mainbot client
  53. print("\nStarting Main Bot\n")
  54. app = Client(
  55. "wbb",
  56. bot_token=BOT_TOKEN,
  57. api_id=API_ID,
  58. api_hash=API_HASH
  59. )
  60. # ARQ client
  61. arq = ARQ(ARQ_API)