Python 带有lambda的电报bot消息处理程序

Python 带有lambda的电报bot消息处理程序,python,lambda,bots,telegram,message-handlers,Python,Lambda,Bots,Telegram,Message Handlers,我正在尝试将@bot.message_处理程序与lambda一起使用,以捕获使用我的bot在组中发送的消息中的一些单词。我看到很多例子,每个人都使用类似的代码: import telebot telebot.logger.setLevel(__import__('logging').DEBUG) bot_token = 'Blablabla' bot = telebot.TeleBot(bot_token) # filter on a specific message @bot.mess

我正在尝试将@bot.message_处理程序与lambda一起使用,以捕获使用我的bot在组中发送的消息中的一些单词。我看到很多例子,每个人都使用类似的代码:

import telebot

telebot.logger.setLevel(__import__('logging').DEBUG)

bot_token = 'Blablabla'

bot = telebot.TeleBot(bot_token)

# filter on a specific message
@bot.message_handler(func=lambda message: message.text == "hi")
def command_text_hi(m):
    bot.send_message(m.chat.id, "I love you too!")

@bot.message_handler(commands=['start'])
def send_welcome(m):
    bot.send_message(m.chat.id, 'Welcome!')

@bot.message_handler(func=lambda message: True, content_types=['text'])
def command_default(m):
    # this is the standard reply to a normal message
    bot.send_message(m.chat.id, "I don't understand, try with /help")

bot.polling()
它运行,但如果我在群中发送“嗨”(机器人在里面),机器人不会说“我也爱你!”我也不知道为什么。但是如果我说/开始,机器人会说“欢迎!!”

我尝试使用@bot.message\u处理程序(func=lambda message:True),正如我在中看到的那样,但它仍然不起作用

如何使用消息处理程序并捕获消息中的一些单词?

默认情况下,为电报机器人程序启用

在隐私模式下运行的bot不会接收人们发送给该组的所有消息。相反,它将只接收:

以斜杠“/”开头的消息(请参见上面的命令)

回复机器人自己的消息

服务消息(从组中添加或删除的人员等)

来自其成员所在频道的消息


您可以通过BotFather为您的机器人禁用隐私模式。

您好,我刚刚启动了您的代码,没有遇到任何问题。请在导入telebot后插入这一行
telebot.logger.setLevel(\uuuu import\uuuuu('logging').DEBUG)
,然后尝试与您的bot通信并共享日志,您的程序将打印出来。当我说“嗨”时,什么都没有结束。当我尝试“/嗨”时,它起作用了。仅在使用编写时有效/如何停用调试模式?我删除了行“telebot.logger.setLevel(\uuuu import\uuuu('logging').DEBUG)”,但它继续显示它。