From ce119ac01838d7b019ad3a68b5762c83a58e0b13 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Tue, 2 Aug 2022 22:37:33 +0800 Subject: [PATCH] fix a bug --- defs/model.py | 2 +- plugins/track.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/defs/model.py b/defs/model.py index 6e9485e..b0ac5fb 100644 --- a/defs/model.py +++ b/defs/model.py @@ -23,6 +23,6 @@ class New: self.publish_time_human = strf_time(self.publish_time) self.title = data.get("title", "") self.summary = data.get("summary", "") - self.text = f"{self.title}\n\n{self.summary}" + self.text = f"{self.title}\n\n{self.summary}\n\n{self.publish_time_human} | @jiemianNews" self.img_urls = [img.get("thumb", "") for img in data.get("img_urls", [])] self.img_url = next((i for i in self.img_urls if i), "") diff --git a/plugins/track.py b/plugins/track.py index fe31507..cc597af 100644 --- a/plugins/track.py +++ b/plugins/track.py @@ -37,7 +37,7 @@ async def send_new_photo(new: New): async def send_new(new: New): - return await send_new_photo(new) if new.img_urls 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") @@ -47,6 +47,7 @@ async def run_every_10_minute(): for new in news: try: await send_new(new) + print(f"{new.title} sent") except FloodWait as e: print(f"Send document flood - Sleep for {e.value} second(s)") await sleep(e.value + uniform(0.5, 1.0)) @@ -56,6 +57,7 @@ async def run_every_10_minute(): with contextlib.suppress(Exception): await app.send_message(admin_id, f"Error: {traceback.format_exc()}") await sleep(uniform(0.5, 2.0)) + print("run ok!") @Client.on_message(filters.incoming & filters.private & filters.chat(admin_id) &