From c11e2d8d6ade2a39dfc9a28b2724315a88815a2c Mon Sep 17 00:00:00 2001 From: zayac Date: Sun, 21 Apr 2024 11:24:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=BD=E8=A7=86=E7=BD=91=E7=BB=9C=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=AF=BC=E8=87=B4=E7=A8=8B=E5=BA=8F=E4=B8=AD=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/change_url/change_url_bot.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/change_url/change_url_bot.py b/src/change_url/change_url_bot.py index ddb94aa..df7a2ef 100644 --- a/src/change_url/change_url_bot.py +++ b/src/change_url/change_url_bot.py @@ -1,10 +1,11 @@ import telebot import requests +import time from loguru import logger from src.change_url.change_url import change_url -TOKEN = '6013830443:AAGzq1Tgtr_ZejU7bv0mab14xOwi0_64d0w' +TOKEN = '6356456493:AAF2J03isyhlOFF6WgoovRCzuvHheTrTKmM' bot = telebot.TeleBot(TOKEN) ky = ['技术客服域名值班'] hth = ['YYZBH②拒绝私聊', '3-信息同步频道'] @@ -49,4 +50,16 @@ def handle_forwarded_message(message): bot.reply_to(message, msg) -bot.polling(none_stop=True) +def start_polling(): + while True: + try: + bot.polling(none_stop=True) + except Exception as e: + logger.error(f"长轮询异常: {e}") + # 在重新尝试前暂停一段时间 + time.sleep(15) + + +if __name__ == "__main__": + start_polling() # 开始长轮询 +