[英]Telegram bot (pyTelegramBotAPI) does not handle new user joining group
I have recently created a simple bot for telegram using the pyTelegramBotAPI (telebot).我最近使用 pyTelegramBotAPI (telebot) 创建了一个简单的电报机器人。 I added a message handler that is supposed to handle every message, including the ones that appear on a group when a new user joins, which are still
Message
objects a non-null new_chat_members
property.我添加了一个消息处理程序,它应该处理每条消息,包括新用户加入时出现在组中的消息,它们仍然是
Message
对象和非空的new_chat_members
属性。
import telebot
bot = telebot.TeleBot(TOKEN)
[...]
@bot.message_handler(func=lambda m: True)
def foo(message):
bot.send_message(message.chat.id,"I got the message")
bot.polling()
Even so, the bot does not reply with the "I got the message" string when I add a new user, although it does catch other messages.即便如此,当我添加新用户时,机器人不会回复“我收到消息”字符串,尽管它确实会捕获其他消息。
Why is this happening?为什么会这样? Is this a problem about the message handler?
这是消息处理程序的问题吗? Is there maybe a more general handler that is sure to catch every update?
是否有更通用的处理程序可以确保捕获每个更新?
Thank you谢谢
you should specify " new_chat_members
" as content-types
.您应该将“
new_chat_members
”指定为content-types
。
Here is a sample working snippet that welcomes new users:这是一个欢迎新用户的示例工作片段:
import telebot
bot = telebot.TeleBot(TOKEN)
@bot.message_handler(content_types=[
"new_chat_members"
])
def foo(message):
bot.reply_to(message, "welcome")
bot.polling()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.