fix a bug

This commit is contained in:
xtaodada 2022-08-02 23:19:16 +08:00
parent 86b5c78837
commit dad4f45f46
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659

View File

@ -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) 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 update_track(time: int = None):
async def run_every_10_minute(): news = await get_news(time)
news = await get_news()
news = sorted(news, key=lambda x: x.publish_time, reverse=False) news = sorted(news, key=lambda x: x.publish_time, reverse=False)
for new in news: for new in news:
try: try:
@ -60,6 +59,11 @@ async def run_every_10_minute():
print("run ok!") 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) & @Client.on_message(filters.incoming & filters.private & filters.chat(admin_id) &
filters.command(["force_update", ])) filters.command(["force_update", ]))
async def force_update(_: Client, message: Message): 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()) a = int(message.text.replace("/force_update", "").strip())
except ValueError: except ValueError:
a = None a = None
await run_every_10_minute(a) await update_track(a)
await message.reply("ok!") await message.reply("ok!")