diff --git a/plugins/tgbot/startup/extend/push_bbs.py b/plugins/tgbot/startup/extend/push_bbs.py index 4c0b1dbc7..0b5ce82f8 100644 --- a/plugins/tgbot/startup/extend/push_bbs.py +++ b/plugins/tgbot/startup/extend/push_bbs.py @@ -11,5 +11,5 @@ import base64 import threading -def run(): +def run(bot): print("!11") diff --git a/plugins/tgbot/startup/extend/receive_faq.py b/plugins/tgbot/startup/extend/receive_faq.py index 031efe3e9..6072d16b9 100644 --- a/plugins/tgbot/startup/extend/receive_faq.py +++ b/plugins/tgbot/startup/extend/receive_faq.py @@ -7,8 +7,38 @@ import json import base64 import threading -import telebot +# import telebot +cmd_list = [ + '/?:', +] + + +def isThisCmd(cmd, msg): + clen = len(cmd) + msg_len = len(msg) + if msg_len < clen: + return False + + check_msg = msg[0:clen] + if cmd == check_msg: + return True + return False + + +def searchFaq(bot, message): + # print(search_text) + bot.reply_to(message, message.chat.id) + return True def run(bot, message): + text_body = message.text + for cmd in cmd_list: + if isThisCmd(cmd, text_body): + return searchFaq(bot, message) + return bot + + +if __name__ == "__main__": + print(isThisCmd('/?:', '/?:如何在安装面板')) diff --git a/plugins/tgbot/startup/tgbot.py b/plugins/tgbot/startup/tgbot.py index f768320f5..b051cb985 100644 --- a/plugins/tgbot/startup/tgbot.py +++ b/plugins/tgbot/startup/tgbot.py @@ -85,14 +85,7 @@ while True: bot = telebot.TeleBot(cfg['bot']['app_token']) -# from telebot.async_telebot import AsyncTeleBot -# import asyncio -# bot = AsyncTeleBot(cfg['bot']['app_token']) - - -# use in for delete with the necessary scope and language_code if necessary bot.delete_my_commands(scope=None, language_code=None) - bot.set_my_commands( commands=[ telebot.types.BotCommand("start", "查看帮助信息"), @@ -123,7 +116,9 @@ def all_message(message): script = r['name'].split('.')[0] __import__(script).run(bot, message) except Exception as e: - pass + writeLog('-----all_message error start -------') + writeLog(mw.getTracebackInfo()) + writeLog('-----all_message error end -------') def runBotPushTask(): @@ -133,7 +128,9 @@ def runBotPushTask(): script = p['name'].split('.')[0] __import__(script).run(bot) except Exception as e: - pass + writeLog('-----runBotPushTask error start -------') + writeLog(mw.getTracebackInfo()) + writeLog('-----runBotPushTask error end -------') def botPush():