33 lines
859 B
Python

import nonebot
from nonebot import require, logger
require("nonebot_plugin_apscheduler")
from pathlib import Path
from nonebot_plugin_apscheduler import scheduler
from .config import pconfig
from .lib import rlib
from .sync import sync
driver = nonebot.get_driver()
@driver.on_startup
def startup():
if pconfig.proxy:
rlib.set_proxy(pconfig.proxy)
if pconfig.github_token:
rlib.set_ghp(pconfig.github_token)
try:
rlib.set_log_level(logger._core.extra.get("nonebot_log_level", "INFO"))
except Exception as e:
logger.error(f"设置日志等级失败: {e}")
rlib.boot(str(Path.cwd()), "nonebot_plugin_sekai_update_notify", pconfig.assets_studio_path)
scheduler.add_job(sync, "interval", seconds=10, id="sekai_update_sync", replace_existing=True)
@driver.on_shutdown
def shutdown():
rlib.stop()