简体   繁体   English

电报机器人(pyTelegramBotAPI)不处理新用户加入组

[英]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.

相关问题 使用电报机器人 pytelegrambotapi 从群组回复用户的消息 - Reply to user's message from group using telegram bot pytelegrambotapi 带有 pyTelegramBotAPI 的电报测验机器人 - Telegram Quiz Bot with pyTelegramBotAPI 通过 pyTelegramBotAPI 在电报机器人中获取照片 - Get photo in telegram bot through pyTelegramBotAPI 如何使用 pytelegrambotapi 在电报组中删除“新聊天成员”消息? - How can I delete 'new chat members' messages in telegram group with pytelegrambotapi? 电报漫游器不会从组中删除贴纸 - The telegram bot does not delete stickers from the group 使用 pyTelegramBotAPI 将电报机器人部署到 Heroku 时使用开放端口 - Use an open port when deploying telegram bot using pyTelegramBotAPI to Heroku 在 PyTelegramBotAPI 上运行的 Telegram Bot 错误地获取转发的消息 - Telegram Bot running on PyTelegramBotAPI is incorrectly getting forwarded messages 如何处理和删除python-telegram-bot中的“​​加入群组”消息? - How to handle and remove “joined the group” messages in python-telegram-bot? Python Telegram Bot:显示新群组成员的消息历史记录 - Python Telegram Bot: show message history for new group members 如何从Telegram Bot的分组消息中获取User对象 - How to get a User object from a message in group at Telegram Bot
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM