From dad4f45f46d9733affc1ece41172d4df4968acc3 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Tue, 2 Aug 2022 23:19:16 +0800 Subject: [PATCH] fix a bug --- plugins/track.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/track.py b/plugins/track.py index da1b125..0a85f43 100644 --- a/plugins/track.py +++ b/plugins/track.py @@ -40,9 +40,8 @@ async def send_new(new: New): return await send_new_photo(new) if new.img_url else await send_new_text(new) -@scheduler.scheduled_job("cron", minute="*/10", id="track") -async def run_every_10_minute(): - news = await get_news() +async def update_track(time: int = None): + news = await get_news(time) news = sorted(news, key=lambda x: x.publish_time, reverse=False) for new in news: try: @@ -60,6 +59,11 @@ async def run_every_10_minute(): print("run ok!") +@scheduler.scheduled_job("cron", minute="*/10", id="track") +async def run_every_10_minute(): + await update_track() + + @Client.on_message(filters.incoming & filters.private & filters.chat(admin_id) & filters.command(["force_update", ])) async def force_update(_: Client, message: Message): @@ -67,5 +71,5 @@ async def force_update(_: Client, message: Message): a = int(message.text.replace("/force_update", "").strip()) except ValueError: a = None - await run_every_10_minute(a) + await update_track(a) await message.reply("ok!")