__init__.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. from config import (
  2. BOT_TOKEN, API_ID, API_HASH, OWNER_ID, SUDO_USER_ID,
  3. LOG_GROUP_ID, FERNET_ENCRYPTION_KEY, MONGO_DB_URI,
  4. WELCOME_DELAY_KICK_SEC, ARQ_API_BASE_URL as ARQ_API,
  5. PHONE_NUMBER
  6. )
  7. from pyrogram import Client
  8. from pytgcalls import GroupCall
  9. from motor.motor_asyncio import AsyncIOMotorClient as MongoClient
  10. from Python_ARQ import ARQ
  11. import time
  12. import logging
  13. f = open("error.log", "w")
  14. f.write("PEAK OF LOG FILE")
  15. LOG_FORMAT = (
  16. '''
  17. [%(asctime)s.%(msecs)03d] %(filename)s:%(lineno)s
  18. %(levelname)s: %(message)s''')
  19. logging.basicConfig(
  20. level=logging.INFO,
  21. format=LOG_FORMAT,
  22. datefmt="%m-%d %H:%M",
  23. filename="error.log",
  24. filemode="w",
  25. )
  26. console = logging.StreamHandler()
  27. console.setLevel(logging.ERROR)
  28. formatter = logging.Formatter(LOG_FORMAT)
  29. console.setFormatter(formatter)
  30. logging.getLogger("").addHandler(console)
  31. log = logging.getLogger()
  32. FERNET_ENCRYPTION_KEY = FERNET_ENCRYPTION_KEY
  33. WELCOME_DELAY_KICK_SEC = WELCOME_DELAY_KICK_SEC
  34. LOG_GROUP_ID = LOG_GROUP_ID
  35. SUDOERS = SUDO_USER_ID
  36. SUDOERS.append(OWNER_ID)
  37. MOD_LOAD = []
  38. MOD_NOLOAD = []
  39. bot_start_time = time.time()
  40. mongo_client = MongoClient(MONGO_DB_URI)
  41. db = mongo_client.wbb
  42. # Userbot client
  43. print("\nStarting Helper Userbot")
  44. app2 = Client(
  45. "userbot",
  46. phone_number=PHONE_NUMBER,
  47. api_id=API_ID,
  48. api_hash=API_HASH
  49. )
  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. # Pytgcalls client
  59. vc = GroupCall(
  60. app2,
  61. input_filename="input.raw",
  62. play_on_repeat=False,
  63. enable_logs_to_console=False
  64. )
  65. # ARQ client
  66. arq = ARQ(ARQ_API)