__init__.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. FERNET_ENCRYPTION_KEY = FERNET_ENCRYPTION_KEY
  33. WELCOME_DELAY_KICK_SEC = WELCOME_DELAY_KICK_SEC
  34. LOG_GROUP_ID = LOG_GROUP_ID
  35. MOD_LOAD = []
  36. MOD_NOLOAD = []
  37. bot_start_time = time.time()
  38. mongo_client = MongoClient(MONGO_DB_URI)
  39. db = mongo_client.wbb
  40. # Userbot client
  41. print("\nStarting Helper Userbot\n")
  42. app2 = Client(
  43. "userbot",
  44. phone_number=PHONE_NUMBER,
  45. api_id=API_ID,
  46. api_hash=API_HASH
  47. )
  48. with app2:
  49. SUDOERS.append((app2.get_me()).id)
  50. # Mainbot client
  51. print("\nStarting Main Bot\n")
  52. app = Client(
  53. "wbb",
  54. bot_token=BOT_TOKEN,
  55. api_id=API_ID,
  56. api_hash=API_HASH
  57. )
  58. # ARQ client
  59. arq = ARQ(ARQ_API)