From b126213c4960094c9ccb904d3f9b9547229de759 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Sun, 20 Mar 2022 02:08:54 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20floodwait=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/ping.py | 2 +- plugins/track.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/ping.py b/plugins/ping.py index 0199fac..4e49f15 100644 --- a/plugins/ping.py +++ b/plugins/ping.py @@ -4,5 +4,5 @@ from pyrogram.types import Message @Client.on_message(filters.incoming & filters.private & filters.command(["ping", ])) -async def force_update(bot: Client, message: Message): +async def ping_check(bot: Client, message: Message): await message.reply("poi ~", quote=True) diff --git a/plugins/track.py b/plugins/track.py index 12e6e93..f5c5f08 100644 --- a/plugins/track.py +++ b/plugins/track.py @@ -15,18 +15,18 @@ from defs.source import update_data, compare, download async def send_track_msg(file, track_msg): if file: await app.send_document(channel_id, file, - caption=track_msg.text, + caption=track_msg.text[:1000], file_name=track_msg.name, force_document=True, parse_mode="html", reply_markup=track_msg.button) else: - await app.send_message(channel_id, track_msg.text, + await app.send_message(channel_id, track_msg.text[:1000], parse_mode="html", reply_markup=track_msg.button) -# @scheduler.scheduled_job("cron", minute="*/30", id="0") +@scheduler.scheduled_job("cron", minute="*/30", id="0") async def run_every_30_minute(): await update_data() need_update = compare() @@ -58,13 +58,14 @@ async def run_every_30_minute(): await send_track_msg(None, track_msg) except FloodWait as e: print(f"Send document flood - Sleep for {e.x} second(s)") - await sleep(uniform(0.5, 1.0)) + await sleep(e.x + uniform(0.5, 1.0)) await send_track_msg(None, track_msg) except ButtonUrlInvalid: print(f"Send button error") await app.send_message(channel_id, track_msg.text, parse_mode="html",) except Exception as e: traceback.print_exc() + await sleep(uniform(0.5, 2.0)) @Client.on_message(filters.incoming & filters.private & filters.chat(admin_id) &