AKMalkadi
AKMalkadi

Reputation: 982

How to handle and remove "joined the group" messages in python-telegram-bot?

I have created a bot to manage my group in telegram using python-telegram-bot. I would like the bot to handle and remove joined/left messages. I am not getting those messages as regular ones. Is there any way to handle them?

I used a bot to do the task for me but this bot started to post ads. I don't trust any existing bots and I would like to create mine using python-telegram-bot since my bot is already built using it.

Upvotes: 0

Views: 2441

Answers (1)

AKMalkadi
AKMalkadi

Reputation: 982

I have solved the issue as follows:

Joined messages can be handled using Filters.status_update.new_chat_members

The following is my code.

def onjoin(update,context):
    context.bot.delete_message(chat_id=update.message.chat_id,message_id=update.message.message_id)
     

def main():
    updater = Updater(API_KEY, use_context=True)
    dp = updater.dispatcher
    dp.add_handler(MessageHandler(Filters.status_update.new_chat_members,onjoin))

Upvotes: 2

Related Questions