__init__.py 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. """
  2. MIT License
  3. Copyright (c) 2021 TheHamkerCat
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in all
  11. copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  18. SOFTWARE.
  19. """
  20. from pyrogram import Client
  21. from pyromod import listen
  22. from motor.motor_asyncio import AsyncIOMotorClient as MongoClient
  23. from Python_ARQ import ARQ
  24. from os import path
  25. import time
  26. is_config = path.exists('config.py')
  27. if is_config:
  28. from config import *
  29. else:
  30. from sample_config import *
  31. SUDOERS = SUDO_USERS_ID
  32. MAIN_CHATS = MAIN_CHATS
  33. GBAN_LOG_GROUP_ID = GBAN_LOG_GROUP_ID
  34. FERNET_ENCRYPTION_KEY = FERNET_ENCRYPTION_KEY
  35. WELCOME_DELAY_KICK_SEC = WELCOME_DELAY_KICK_SEC
  36. LOG_GROUP_ID = LOG_GROUP_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. if not HEROKU:
  43. app2 = Client(
  44. "userbot",
  45. phone_number=PHONE_NUMBER,
  46. api_id=API_ID,
  47. api_hash=API_HASH
  48. )
  49. else:
  50. app2 = Client(
  51. SESSION_STRING,
  52. api_id=API_ID,
  53. api_hash=API_HASH
  54. )
  55. app = Client(
  56. "wbb",
  57. bot_token=BOT_TOKEN,
  58. api_id=API_ID,
  59. api_hash=API_HASH
  60. )
  61. BOT_ID = 0
  62. BOT_NAME = ""
  63. BOT_USERNAME = ""
  64. BOT_MENTION = ""
  65. BOT_DC_ID = 0
  66. USERBOT_ID = 0
  67. USERBOT_NAME = ""
  68. USERBOT_USERNAME = ""
  69. USERBOT_DC_ID = 0
  70. USERBOT_MENTION = ""
  71. def get_info(app, app2):
  72. global BOT_ID, BOT_NAME, BOT_USERNAME, BOT_DC_ID, BOT_MENTION
  73. global USERBOT_ID, USERBOT_NAME, USERBOT_USERNAME, USERBOT_DC_ID, USERBOT_MENTION
  74. getme = app.get_me()
  75. getme2 = app2.get_me()
  76. BOT_ID = getme.id
  77. USERBOT_ID = getme2.id
  78. if getme.last_name:
  79. BOT_NAME = getme.first_name + " " + getme.last_name
  80. else:
  81. BOT_NAME = getme.first_name
  82. BOT_USERNAME = getme.username
  83. BOT_MENTION = getme.mention
  84. BOT_DC_ID = getme.dc_id
  85. if getme2.last_name:
  86. USERBOT_NAME = getme2.first_name + " " + getme2.last_name
  87. else:
  88. USERBOT_NAME = getme2.first_name
  89. USERBOT_USERNAME = getme2.username
  90. USERBOT_MENTION = getme2.mention
  91. USERBOT_DC_ID = getme2.dc_id
  92. app.start()
  93. app2.start()
  94. get_info(app, app2)
  95. SUDOERS.append(USERBOT_ID)
  96. # ARQ client
  97. arq = ARQ(ARQ_API_BASE_URL)