twitter2telegram/plugins/update.py

33 lines
811 B
Python
Raw Normal View History

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
2023-12-01 14:23:51 +00:00
@scheduler.scheduled_job("cron", minute="*/15", id="update_all")
2023-12-01 15:37:49 +00:00
async def update_all_15_minutes():
if _lock.locked():
return
async with _lock:
await check_update()