diff --git a/bot.py b/bot.py index 8a19a52..6e84d65 100644 --- a/bot.py +++ b/bot.py @@ -107,6 +107,6 @@ async def _start(): checking() from module.init import init_task - init_task() + init_task(app) run_fastapi() app.run() diff --git a/module/init.py b/module/init.py index df0e77d..5df3028 100644 --- a/module/init.py +++ b/module/init.py @@ -1,10 +1,9 @@ -from bot import app from module.cloudflare.storage_mgmt import start_bandwidth_push, start_status_push from module.cloudflare.proxy_load_balancing import init_node from module.timed_backup.timed_backup import start_timed_backup -def init_task(): +def init_task(app): start_timed_backup(app) start_bandwidth_push(app) start_status_push(app) diff --git a/module/timed_backup/timed_backup.py b/module/timed_backup/timed_backup.py index 3de2eb6..e92121c 100644 --- a/module/timed_backup/timed_backup.py +++ b/module/timed_backup/timed_backup.py @@ -64,7 +64,7 @@ async def send_backup_file(_, message: Message): # 定时任务——发送备份文件 -async def recovery_send_backup_file(cli): +async def recovery_send_backup_file(cli: Client): bc_file_name = await backup_config() await cli.send_document( chat_id=bot_cfg.admin, document=bc_file_name, caption="#Alist配置定时备份" @@ -86,7 +86,7 @@ def start_timed_backup(app): # 设置备份时间&开启定时备份 @Client.on_message(filters.command("sbt") & filters.private & is_admin) -async def set_backup_time(_, message: Message): +async def set_backup_time(cli: Client, message: Message): mtime = " ".join(message.command[1:]) if len(mtime.split()) == 5: bot_cfg.backup_time = mtime @@ -103,6 +103,7 @@ async def set_backup_time(_, message: Message): func=recovery_send_backup_file, trigger=CronTrigger.from_crontab(bot_cfg.backup_time), job_id="send_backup_messages_regularly_id", + args=[cli], ) text = f"已开启定时备份!\n下一次备份时间:{next_run_time}" await message.reply(text)