fix a bug
This commit is contained in:
parent
cbbbb9c6a6
commit
ce119ac018
@ -23,6 +23,6 @@ class New:
|
|||||||
self.publish_time_human = strf_time(self.publish_time)
|
self.publish_time_human = strf_time(self.publish_time)
|
||||||
self.title = data.get("title", "")
|
self.title = data.get("title", "")
|
||||||
self.summary = data.get("summary", "")
|
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_urls = [img.get("thumb", "") for img in data.get("img_urls", [])]
|
||||||
self.img_url = next((i for i in self.img_urls if i), "")
|
self.img_url = next((i for i in self.img_urls if i), "")
|
||||||
|
@ -37,7 +37,7 @@ async def send_new_photo(new: New):
|
|||||||
|
|
||||||
|
|
||||||
async def send_new(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")
|
@scheduler.scheduled_job("cron", minute="*/10", id="track")
|
||||||
@ -47,6 +47,7 @@ async def run_every_10_minute():
|
|||||||
for new in news:
|
for new in news:
|
||||||
try:
|
try:
|
||||||
await send_new(new)
|
await send_new(new)
|
||||||
|
print(f"{new.title} sent")
|
||||||
except FloodWait as e:
|
except FloodWait as e:
|
||||||
print(f"Send document flood - Sleep for {e.value} second(s)")
|
print(f"Send document flood - Sleep for {e.value} second(s)")
|
||||||
await sleep(e.value + uniform(0.5, 1.0))
|
await sleep(e.value + uniform(0.5, 1.0))
|
||||||
@ -56,6 +57,7 @@ async def run_every_10_minute():
|
|||||||
with contextlib.suppress(Exception):
|
with contextlib.suppress(Exception):
|
||||||
await app.send_message(admin_id, f"Error: {traceback.format_exc()}")
|
await app.send_message(admin_id, f"Error: {traceback.format_exc()}")
|
||||||
await sleep(uniform(0.5, 2.0))
|
await sleep(uniform(0.5, 2.0))
|
||||||
|
print("run ok!")
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(filters.incoming & filters.private & filters.chat(admin_id) &
|
@Client.on_message(filters.incoming & filters.private & filters.chat(admin_id) &
|
||||||
|
Loading…
Reference in New Issue
Block a user