Files
nonebot_sekai_update_notify/__init__.py
T
2026-10-25 20:29:05 +08:00

48 lines
1.0 KiB
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
from . import command
driver = nonebot.get_driver()
@driver.on_startup
def startup():
if pconfig.proxy:
rlib.set_proxy(pconfig.proxy)
if pconfig.pjsk_proxy:
rlib.set_pjsk_proxy(pconfig.pjsk_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}")
flag = False
@driver.on_bot_connect
def _():
global flag
if flag:
return
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)
flag = True
@driver.on_shutdown
def shutdown():
rlib.stop()