__init__.py 3.0 KB

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