pull/391/head
midoks 2 years ago
parent 197e2d80c6
commit 29e3017e51
  1. 1
      plugins/tgbot/index.html
  2. 10
      plugins/tgbot/index.py
  3. 12
      plugins/tgbot/startup/tgbot.py

@ -5,6 +5,7 @@
<p class="bgw" onclick="pluginService('tgbot');">服务</p>
<p onclick="pluginInitD('tgbot');">自启动</p>
<p onclick="botConf();">Bot配置</p>
<p onclick="pluginLogs('tgbot','','run_log');">日志</p>
</div>
<div class="bt-w-con pd15">
<div class="soft-man-con"></div>

@ -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')

@ -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())

Loading…
Cancel
Save