__init__.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. app2 = Client(
  41. "userbot",
  42. phone_number=PHONE_NUMBER,
  43. api_id=API_ID,
  44. api_hash=API_HASH
  45. )
  46. app = Client(
  47. "wbb",
  48. bot_token=BOT_TOKEN,
  49. api_id=API_ID,
  50. api_hash=API_HASH
  51. )
  52. BOT_ID = 0
  53. BOT_NAME = ""
  54. BOT_USERNAME = ""
  55. BOT_MENTION = ""
  56. BOT_DC_ID = 0
  57. USERBOT_ID = 0
  58. USERBOT_NAME = ""
  59. USERBOT_USERNAME = ""
  60. USERBOT_DC_ID = 0
  61. USERBOT_MENTION = ""
  62. def get_info(app, app2):
  63. global BOT_ID, BOT_NAME, BOT_USERNAME, BOT_DC_ID, BOT_MENTION
  64. global USERBOT_ID, USERBOT_NAME, USERBOT_USERNAME, USERBOT_DC_ID, USERBOT_MENTION
  65. getme = app.get_me()
  66. getme2 = app2.get_me()
  67. BOT_ID = getme.id
  68. USERBOT_ID = getme2.id
  69. if getme.last_name:
  70. BOT_NAME = getme.first_name + " " + getme.last_name
  71. else:
  72. BOT_NAME = getme.first_name
  73. BOT_USERNAME = getme.username
  74. BOT_MENTION = getme.mention
  75. BOT_DC_ID = getme.dc_id
  76. if getme2.last_name:
  77. USERBOT_NAME = getme2.first_name + " " + getme2.last_name
  78. else:
  79. USERBOT_NAME = getme2.first_name
  80. USERBOT_USERNAME = getme2.username
  81. USERBOT_MENTION = getme2.mention
  82. USERBOT_DC_ID = getme2.dc_id
  83. app.start()
  84. app2.start()
  85. get_info(app, app2)
  86. SUDOERS.append(USERBOT_ID)
  87. # ARQ client
  88. arq = ARQ(ARQ_API)