Telegram bot (pyTelegramBotAPI) does not handle new user joining group

Viewed 3419

I have recently created a simple bot for telegram using the 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.

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

1 Answers

you should specify "new_chat_members" as 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()
Related