2023-12-01 15:37:49 +00:00
|
|
|
from asyncio import Lock
|
|
|
|
|
2023-05-24 15:20:21 +00:00
|
|
|
from pyrogram.types import Message
|
|
|
|
|
|
|
|
from defs.glover import owner
|
|
|
|
from init import bot
|
|
|
|
from scheduler import scheduler
|
|
|
|
|
|
|
|
from pyrogram import filters
|
|
|
|
|
|
|
|
from defs.update import check_update
|
|
|
|
|
2023-12-01 15:37:49 +00:00
|
|
|
_lock = Lock()
|
|
|
|
|
2023-05-24 15:20:21 +00:00
|
|
|
|
|
|
|
@bot.on_message(filters=filters.command("check_update") & filters.user(owner))
|
|
|
|
async def update_all(_, message: Message):
|
2023-12-01 15:37:49 +00:00
|
|
|
if _lock.locked():
|
|
|
|
await message.reply("正在检查更新,请稍后再试!")
|
|
|
|
return
|
|
|
|
async with _lock:
|
|
|
|
msg = await message.reply("开始检查更新!")
|
|
|
|
await check_update()
|
|
|
|
await msg.edit("检查更新完毕!")
|
2023-05-24 15:20:21 +00:00
|
|
|
|
|
|
|
|
2024-02-17 05:50:20 +00:00
|
|
|
@scheduler.scheduled_job("cron", hour="*", minute="0", id="update_all")
|
|
|
|
async def update_all_60_minutes():
|
2023-12-01 15:37:49 +00:00
|
|
|
if _lock.locked():
|
|
|
|
return
|
|
|
|
async with _lock:
|
|
|
|
await check_update()
|