From 27316040f9febdcbc4c2bcfaef83ff3730f91aa5 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Tue, 2 Aug 2022 23:16:25 +0800 Subject: [PATCH] support custom time --- defs/get_news.py | 5 +++-- plugins/track.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/defs/get_news.py b/defs/get_news.py index 29bc4a0..3de3d63 100644 --- a/defs/get_news.py +++ b/defs/get_news.py @@ -5,8 +5,9 @@ from ci import client, sqlite from defs.model import New -async def get_news() -> List[New]: - time = sqlite.get("update_time", time_.time() - 600) +async def get_news(time: int=None) -> List[New]: + if not time: + time = sqlite.get("update_time", int(time_.time()) - 600) url = f"https://papi.jiemian.com/page/api/kuaixun/getLastest?cid=1325kb&end_time={time}&tagid=1325" data = await client.get(url) if data.status_code != 200: diff --git a/plugins/track.py b/plugins/track.py index cc597af..0066044 100644 --- a/plugins/track.py +++ b/plugins/track.py @@ -63,5 +63,6 @@ async def run_every_10_minute(): @Client.on_message(filters.incoming & filters.private & filters.chat(admin_id) & filters.command(["force_update", ])) async def force_update(_: Client, message: Message): - await run_every_10_minute() + a = int(message.text.replace("/force_update", "").strip()) + await run_every_10_minute(a) await message.reply("ok!")