1

Relates to Retrieve all chat ids using Telegram bot but 3 years later.

My use case is a bot that notifies chat participants of home automation events. Any user might create his own chat and receive events or send commands.

Currently, it seems that the bot has no option to find the chats that it participates in. Even a potential workaround like using GetUpdates(0) seems to retrieve only new message ids which makes it impossible to get a complete list of chats from looking at the received messages.

Is there a stable solution for doing this?

andig
  • 13,378
  • 13
  • 61
  • 98

1 Answers1

1

This is not possible from Telegram's API. Howerver,

A bot will receive a new_chat_members which could be the bot 'joining another group':

new_chat_members -- Array of User -- Optional.

New members that were added to the group or supergroup and information about them (the bot itself may be one of these members)

To remember each user/group, you'll have to save each chat/user_id into a database.

The bot will also receive the opposite left_chat_member so you'll know when to delete a database entry.

Community
  • 1
  • 1
0stone0
  • 34,288
  • 4
  • 39
  • 64
  • 1
    That requires to bot to always be running. Too nad telegram doesn‘t support this. – andig Mar 26 '20 at 20:47
  • 1
    @andig If you rather not have a daemon, have you considered a [webhook bot](https://core.telegram.org/bots/api#setwebhook) that will receive a _HTTPS POST_ request for each update? – 0stone0 Mar 26 '20 at 20:51