From c15348b14a5b8ce3c9278fac86e97c38ec311aea Mon Sep 17 00:00:00 2001 From: BennyThink Date: Fri, 15 Apr 2022 20:12:22 +0800 Subject: [PATCH] exception Handle in ping --- requirements.txt | 10 +++++----- ytdlbot/db.py | 5 ++++- ytdlbot/utils.py | 3 ++- ytdlbot/ytdl_bot.py | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/requirements.txt b/requirements.txt index 1d36c5f..28aadb7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,21 +1,21 @@ -pyrogram==1.4.8 +pyrogram==1.4.15 tgcrypto==1.2.3 -yt-dlp==2022.3.8.2 +yt-dlp==2022.4.8 APScheduler==3.9.1 beautifultable==1.0.1 ffmpeg-python==0.2.0 PyMySQL==1.0.2 -celery==5.2.3 +celery==5.2.6 filetype==1.0.10 flower==1.0.0 psutil==5.9.0 influxdb==5.3.1 -beautifulsoup4==4.10.0 +beautifulsoup4==4.11.1 fakeredis==1.7.1 supervisor==4.2.4 tgbot-ping==1.0.4 redis==4.1.4 requests==2.27.1 -tqdm==4.63.0 +tqdm==4.64.0 requests-toolbelt==0.9.1 ffpb==0.4.1 \ No newline at end of file diff --git a/ytdlbot/db.py b/ytdlbot/db.py index 7d6f791..15e2a01 100644 --- a/ytdlbot/db.py +++ b/ytdlbot/db.py @@ -235,7 +235,10 @@ class InfluxDB: username = os.getenv("FLOWER_USERNAME", "benny") token = base64.b64encode(f"{username}:{password}".encode()).decode() headers = {"Authorization": f"Basic {token}"} - return requests.get("https://celery.dmesg.app/dashboard?json=1", headers=headers).json() + r = requests.get("https://celery.dmesg.app/dashboard?json=1", headers=headers) + if r.status_code != 200: + return dict(data=[]) + return r.json() def extract_dashboard_data(self): self.data = self.get_worker_data() diff --git a/ytdlbot/utils.py b/ytdlbot/utils.py index 7a0677c..642d67f 100644 --- a/ytdlbot/utils.py +++ b/ytdlbot/utils.py @@ -187,7 +187,8 @@ class Detector: "Code is updated", 'Retrying "messages.GetMessages"', "OSError: Connection lost", - "[Errno -3] Try again" + "[Errno -3] Try again", + "MISCONF", ] for indicator in indicators: if indicator in self.logs: diff --git a/ytdlbot/ytdl_bot.py b/ytdlbot/ytdl_bot.py index cacc02e..a2cc969 100644 --- a/ytdlbot/ytdl_bot.py +++ b/ytdlbot/ytdl_bot.py @@ -161,7 +161,7 @@ def ping_handler(client: "Client", message: "types.Message"): else: bot_info = get_runtime("ytdlbot_ytdl_1", "YouTube-dl") if message.chat.username == OWNER: - stats = bot_text.ping_worker() + stats = bot_text.ping_worker()[:1000] client.send_document(chat_id, Redis().generate_file(), caption=f"{bot_info}\n\n{stats}") else: client.send_message(chat_id, f"{bot_info}")