From 49c7ec6073f97ff520b606aa7e4ab48258b25e13 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 28 Mar 2023 16:31:46 +0800 Subject: [PATCH] Update tgbot.py --- plugins/tgbot/startup/tgbot.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/plugins/tgbot/startup/tgbot.py b/plugins/tgbot/startup/tgbot.py index 48fa2a350..ea5293cf2 100644 --- a/plugins/tgbot/startup/tgbot.py +++ b/plugins/tgbot/startup/tgbot.py @@ -179,6 +179,17 @@ def setDaemon(t): else: t.setDaemon(True) + +def runBot(bot): + try: + bot.polling() + except Exception as e: + writeLog('-----runBot error start -------') + writeLog(str(e)) + writeLog('-----runBot error end -------') + time.sleep(1) + runBot(bot) + if __name__ == "__main__": # 机器人推送任务 @@ -190,5 +201,8 @@ if __name__ == "__main__": botPushOtherTask.start() writeLog('启动成功') - bot.polling() + + runBot(bot) + + # asyncio.run(bot.polling())