R
R
Roman2021-01-16 13:35:20
Python
Roman, 2021-01-16 13:35:20

How to implement an event handler when my Telegram bot is invited to a channel?

Welcome all. I am writing a Telegram bot in Python using the PyTelegramBotAPI library. After reading the documentation, I managed to figure out the incoming message handlers, that is, with a typical design

@bot.message_handler(filters)
def function_name(message):
  ...

But the question arose: what if someone invites my bot to their channel? How can I handle this event ? Namely, you need to get the chat id of the channel where the bot was invited in order to write messages to this channel in the future.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-01-16
@cannev

Bots do not track such an event.
You can only check at each event from which chat id it came and compare it with the list of existing chats. Well, accordingly, if such a chat was not previously in the list - it is new, write down its id and work with it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question