From 609a4ed351c4de1b46230ab5bcc1fcd1aa9845d2 Mon Sep 17 00:00:00 2001 From: midoks Date: Thu, 16 Mar 2023 21:34:44 +0800 Subject: [PATCH] Update tgbot.py --- plugins/tgbot/startup/tgbot.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/plugins/tgbot/startup/tgbot.py b/plugins/tgbot/startup/tgbot.py index ea2ea3453..48fa2a350 100644 --- a/plugins/tgbot/startup/tgbot.py +++ b/plugins/tgbot/startup/tgbot.py @@ -155,6 +155,24 @@ def botPush(): time.sleep(1) +def runBotPushOtherTask(): + plist = getStartExtCfgByTag('other') + for p in plist: + try: + script = p['name'].split('.')[0] + __import__(script).run(bot) + except Exception as e: + writeLog('-----runBotPushOtherTask error start -------') + writeLog(mw.getTracebackInfo()) + writeLog('-----runBotPushOtherTask error end -------') + + +def botPushOther(): + while True: + runBotPushOtherTask() + time.sleep(1) + + def setDaemon(t): if sys.version_info.major == 3 and sys.version_info.minor >= 10: t.daemon = True @@ -165,10 +183,12 @@ if __name__ == "__main__": # 机器人推送任务 botPushTask = threading.Thread(target=botPush) - # print(botPushTask) - # botPushTask = setDaemon(botPushTask) botPushTask.start() + # 机器人其他推送任务 + botPushOtherTask = threading.Thread(target=botPushOther) + botPushOtherTask.start() + writeLog('启动成功') bot.polling() # asyncio.run(bot.polling())