From 29e3017e5108f35abdc8e087167dafdd3b8ac6dc Mon Sep 17 00:00:00 2001 From: midoks Date: Mon, 6 Mar 2023 16:49:42 +0800 Subject: [PATCH] up --- plugins/tgbot/index.html | 1 + plugins/tgbot/index.py | 10 ++++++++-- plugins/tgbot/startup/tgbot.py | 12 +++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/plugins/tgbot/index.html b/plugins/tgbot/index.html index fa1873be6..f98fd5ded 100755 --- a/plugins/tgbot/index.html +++ b/plugins/tgbot/index.html @@ -5,6 +5,7 @@

服务

自启动

Bot配置

+

日志

diff --git a/plugins/tgbot/index.py b/plugins/tgbot/index.py index 6ea4e0926..cd040d32f 100755 --- a/plugins/tgbot/index.py +++ b/plugins/tgbot/index.py @@ -211,6 +211,11 @@ def setBotConf(): return mw.returnJson(True, '保存成功!', []) +def runLog(): + p = getServerDir() + '/task.log' + return p + + if __name__ == "__main__": func = sys.argv[1] if func == 'status': @@ -233,7 +238,8 @@ if __name__ == "__main__": print(getBotConf()) elif func == 'set_bot_conf': print(setBotConf()) - elif func == 'conf': - print(getConf()) + elif func == 'run_log': + print(runLog()) + else: print('error') diff --git a/plugins/tgbot/startup/tgbot.py b/plugins/tgbot/startup/tgbot.py index cd4c530cc..c763e8c1c 100644 --- a/plugins/tgbot/startup/tgbot.py +++ b/plugins/tgbot/startup/tgbot.py @@ -40,6 +40,15 @@ def writeConf(data): mw.writeFile(cfg_path, json.dumps(data)) return True + +def writeLog(log_str): + if __name__ == "__main__": + print(log_str) + + log_file = getServerDir() + '/task.log' + mw.writeFileLog(log_str, log_file, limit_size=5 * 1024) + return True + # start tgbot cfg = getConfigData() while True: @@ -47,7 +56,7 @@ while True: if 'bot' in cfg and 'app_token' in cfg['bot']: if cfg['bot']['app_token'] != '' and cfg['bot']['app_token'] != 'app_token': break - print('wait input config') + writeLog('等待输入配置,填写app_token') time.sleep(3) bot = telebot.TeleBot(cfg['bot']['app_token']) @@ -67,5 +76,6 @@ def hanle_start_help(message): def hanle_get_chat_id(message): bot.reply_to(message, message.chat.id) +writeLog('启动成功') bot.polling() # asyncio.run(bot.polling())