2022-05-23 12:40:30 +00:00
|
|
|
from sys import path, platform
|
|
|
|
from os import sep
|
|
|
|
from importlib import import_module
|
|
|
|
|
|
|
|
from pyrogram import idle
|
2022-12-22 04:00:10 +00:00
|
|
|
from pyrogram.errors import AuthKeyUnregistered
|
2022-05-23 12:40:30 +00:00
|
|
|
|
|
|
|
from pagermaid import bot, logs, working_dir
|
2023-01-31 16:24:56 +00:00
|
|
|
from pagermaid.common.plugin import plugin_manager
|
2022-06-27 13:42:24 +00:00
|
|
|
from pagermaid.hook import Hook
|
2022-05-23 12:40:30 +00:00
|
|
|
from pagermaid.modules import module_list, plugin_list
|
2022-08-01 16:04:45 +00:00
|
|
|
from pagermaid.single_utils import safe_remove
|
2022-06-07 12:44:45 +00:00
|
|
|
from pagermaid.utils import lang, process_exit
|
2023-01-20 13:57:30 +00:00
|
|
|
from pyromod.methods.sign_in_qrcode import start_client
|
2022-05-23 12:40:30 +00:00
|
|
|
|
|
|
|
path.insert(1, f"{working_dir}{sep}plugins")
|
2022-05-27 15:09:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
async def main():
|
|
|
|
logs.info(lang('platform') + platform + lang('platform_load'))
|
|
|
|
|
2022-12-22 04:00:10 +00:00
|
|
|
try:
|
2023-01-20 13:57:30 +00:00
|
|
|
await start_client(bot)
|
2022-12-22 04:00:10 +00:00
|
|
|
except AuthKeyUnregistered:
|
|
|
|
safe_remove("pagermaid.session")
|
|
|
|
exit()
|
2022-05-27 15:09:24 +00:00
|
|
|
|
2022-07-20 04:01:15 +00:00
|
|
|
me = await bot.get_me()
|
2022-08-01 16:04:45 +00:00
|
|
|
if me.is_bot:
|
|
|
|
safe_remove("pagermaid.session")
|
|
|
|
exit()
|
2022-07-20 04:01:15 +00:00
|
|
|
logs.info(f"{lang('save_id')} {me.first_name}({me.id})")
|
|
|
|
|
2022-05-27 15:09:24 +00:00
|
|
|
for module_name in module_list:
|
|
|
|
try:
|
2022-06-20 13:55:14 +00:00
|
|
|
import_module(f"pagermaid.modules.{module_name}")
|
2022-05-27 15:09:24 +00:00
|
|
|
except BaseException as exception:
|
|
|
|
logs.info(f"{lang('module')} {module_name} {lang('error')}: {type(exception)}: {exception}")
|
2022-11-26 03:01:51 +00:00
|
|
|
for plugin_name in plugin_list.copy():
|
2022-05-27 15:09:24 +00:00
|
|
|
try:
|
2022-06-20 13:55:14 +00:00
|
|
|
import_module(f"plugins.{plugin_name}")
|
2022-05-27 15:09:24 +00:00
|
|
|
except BaseException as exception:
|
|
|
|
logs.info(f"{lang('module')} {plugin_name} {lang('error')}: {exception}")
|
|
|
|
plugin_list.remove(plugin_name)
|
2023-01-31 16:24:56 +00:00
|
|
|
plugin_manager.load_local_plugins()
|
2022-05-27 15:09:24 +00:00
|
|
|
|
2022-06-07 12:44:45 +00:00
|
|
|
await process_exit(start=True, _client=bot)
|
2022-05-27 15:09:24 +00:00
|
|
|
logs.info(lang('start'))
|
2022-11-14 14:11:27 +00:00
|
|
|
await Hook.load_success_exec()
|
2022-06-27 13:42:24 +00:00
|
|
|
await Hook.startup()
|
|
|
|
|
2022-05-27 15:09:24 +00:00
|
|
|
await idle()
|
|
|
|
await bot.stop()
|
|
|
|
|
|
|
|
bot.run(main())
|