X
X
XWR2021-08-29 14:42:42
Python
XWR, 2021-08-29 14:42:42

How to catch the event adding a bot to the chat?

Hello Can you please tell me how to catch the event adding a bot to a group?

@dp.message_handler(content_types=['????'])
async def newschat(message: types.Message):
    await message.answer(f"Спасибо что добавили в чат!")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-08-29
@XWR

@dp.message_handler(content_types=['new_chat_members'])
async def send_welcome(message: types.Message):
    bot_obj = await bot.get_me()
    bot_id = bot_obj.id
    
    for chat_member in message.new_chat_members:
        if chat_member.id == bot_id:
            await message.reply("Hi!\nI'm EchoBot!\nPowered by aiogram.")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question