PagerMaid-Pyro/pagermaid/__main__.py
xtaodada 5cb2cac42a
🔖 Update to v1.2.2
Upgrade pyrogram to 2.0.33
Add user info to log
2022-07-20 12:01:15 +08:00

43 lines
1.2 KiB
Python

from sys import path, platform
from os import sep
from importlib import import_module
from pyrogram import idle
from pagermaid import bot, logs, working_dir
from pagermaid.hook import Hook
from pagermaid.modules import module_list, plugin_list
from pagermaid.utils import lang, process_exit
path.insert(1, f"{working_dir}{sep}plugins")
async def main():
logs.info(lang('platform') + platform + lang('platform_load'))
await bot.start()
me = await bot.get_me()
logs.info(f"{lang('save_id')} {me.first_name}({me.id})")
for module_name in module_list:
try:
import_module(f"pagermaid.modules.{module_name}")
except BaseException as exception:
logs.info(f"{lang('module')} {module_name} {lang('error')}: {type(exception)}: {exception}")
for plugin_name in plugin_list:
try:
import_module(f"plugins.{plugin_name}")
except BaseException as exception:
logs.info(f"{lang('module')} {plugin_name} {lang('error')}: {exception}")
plugin_list.remove(plugin_name)
await process_exit(start=True, _client=bot)
logs.info(lang('start'))
await Hook.startup()
await idle()
await bot.stop()
bot.run(main())