Skip to content

Commit

Permalink
Fix: 定时备份
Browse files Browse the repository at this point in the history
  • Loading branch information
z-mio committed Jun 15, 2024
1 parent aea922e commit acbfeb6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,6 @@ async def _start():
checking()
from module.init import init_task

init_task()
init_task(app)
run_fastapi()
app.run()
3 changes: 1 addition & 2 deletions module/init.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
5 changes: 3 additions & 2 deletions module/timed_backup/timed_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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配置定时备份"
Expand All @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit acbfeb6

Please sign in to comment.