fix a bug

This commit is contained in:
xtaodada 2022-08-02 22:37:33 +08:00
parent cbbbb9c6a6
commit ce119ac018
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 4 additions and 2 deletions

View File

@ -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"<b>{self.title}</b>\n\n{self.summary}"
self.text = f"<b>{self.title}</b>\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), "")

View File

@ -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) &