忽视网络问题导致程序中断

This commit is contained in:
zayac 2024-04-21 11:24:52 +08:00
parent b51fdcca32
commit c11e2d8d6a

View File

@ -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() # 开始长轮询