app/main.py

36 lines
1.3 KiB
Python
Raw Normal View History

2024-03-18 18:21:56 +08:00
import nonebot
from nonebot.adapters.onebot import v11, v12
from nonebot.adapters import satori
2024-05-12 02:47:14 +08:00
from liteyuki.utils import init
from liteyuki.utils.base.config import load_from_yaml
from liteyuki.utils.base.data_manager import StoredConfig, common_db
from liteyuki.utils.base.ly_api import liteyuki_api
2024-03-23 19:55:12 +08:00
2024-05-09 00:09:18 +08:00
if __name__ == "__mp_main__":
2024-05-10 00:12:48 +08:00
init()
store_config: dict = common_db.where_one(StoredConfig(), default=StoredConfig()).config
2024-05-10 00:12:48 +08:00
static_config = load_from_yaml("config.yml")
store_config.update(static_config)
nonebot.init(**store_config)
if not store_config.get("enable_satori", False):
2024-05-16 22:15:04 +08:00
adapters = [v11.Adapter, v12.Adapter]
else:
adapters = [v11.Adapter, v12.Adapter, satori.Adapter]
2024-05-09 00:09:18 +08:00
driver = nonebot.get_driver()
2024-03-23 19:55:12 +08:00
2024-05-09 00:09:18 +08:00
for adapter in adapters:
driver.register_adapter(adapter)
try:
2024-05-08 23:40:16 +08:00
nonebot.load_plugin("liteyuki.liteyuki_main")
nonebot.load_from_toml("pyproject.toml")
except BaseException as e:
2024-03-27 08:03:19 +08:00
if not isinstance(e, KeyboardInterrupt):
nonebot.logger.error(f"An error occurred: {e}, Bug will be reported automatically.")
liteyuki_api.bug_report(str(e.__repr__()))
2024-05-09 00:09:18 +08:00
if __name__ == "__main__":
2024-05-12 02:47:14 +08:00
from liteyuki.utils.base.reloader import Reloader
2024-05-09 00:09:18 +08:00
nonebot.run()