From 7ea9f052712202525fa183ee68e5e2c8742ebd3d Mon Sep 17 00:00:00 2001 From: yshtcn Date: Sun, 24 Nov 2024 12:41:36 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E4=BF=AE=E6=94=B9=E4=B8=BA=E5=8F=91?= =?UTF-8?q?=E9=80=81=E6=B6=88=E6=81=AF=E6=97=B6=EF=BC=8C=E4=BC=9A=E5=B0=9D?= =?UTF-8?q?=E8=AF=95=E8=BF=9B=E8=A1=8C3=E6=9D=A1=E9=87=8D=E8=AF=95?= =?UTF-8?q?=E5=8F=91=E9=80=81=20-=20=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E6=97=B6=EF=BC=8C=E5=A6=82=E6=9E=9C=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=BE=85=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF=EF=BC=8C?= =?UTF-8?q?=E4=BC=9A=E8=BF=94=E5=9B=9Ejson=E6=A0=BC=E5=BC=8F=E7=9A=84ok=20?= =?UTF-8?q?-=20=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF=E6=88=90=E5=8A=9F?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=A6=82=E6=9E=9C=E6=9C=89=E5=BE=85=E5=8F=91?= =?UTF-8?q?=E9=80=81=E7=9A=84=E6=B6=88=E6=81=AF=EF=BC=8C=E5=B9=B6=E4=B8=94?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E5=8F=91=E9=80=81=E4=BA=863=E6=9D=A1?= =?UTF-8?q?=E6=B6=88=E6=81=AF=EF=BC=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ServerChanPush2TelegramBot.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/ServerChanPush2TelegramBot.py b/ServerChanPush2TelegramBot.py index 3ef473d..0012df7 100644 --- a/ServerChanPush2TelegramBot.py +++ b/ServerChanPush2TelegramBot.py @@ -343,7 +343,30 @@ def index(): # new_pending_messages.append(msg) # # 更新待发送消息列表,只包含失败的消息 # write_pending_messages(new_pending_messages) - return jsonify(response), 200 + pending_messages = read_pending_messages() + pending_count = len(pending_messages) + + if pending_count == 0: + # 如果没有待发送消息,直接返回与 TestStatus == '3' 一致的结构 + return jsonify({ + "ok": "send message success", + "response": response, + }), 200 + + # 调用批量发送逻辑,每次最多发送10条 + result = send_messages_in_batches(batch_size=3) + + # 读取剩余待发送消息数量 + remaining_messages = read_pending_messages() + remaining_count = len(remaining_messages) + + # 返回结果与 TestStatus == '3' 保持一致,并增加成功发送条数 + return jsonify({ + "ok": "send message success and batch processed", + "pending_messages_count": pending_count, + "remaining_pending_messages_count": remaining_count, + "successfully_sent_count": result["successfully_sent_count"] + }), 200 else: current_timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") if "【This is a delayed message】" not in desp: