In python-telegram-bot how to get all participants of the group?

Thomas8 picture Thomas8 · Jan 2, 2016 · Viewed 17.6k times · Source

In Python-telegram-bot how to get, if possible, the complete list of all participants of the group at which the bot was added?

Answer

unnikked picture unnikked · Jan 8, 2016

You can't with current API but you could the join/exit of user members via it's API.

If you check the Message object you find :

  • new_chat_participant: A new member was added to the group, information about them (this member may be the bot itself)
  • left_chat_participant: A member was removed from the group, information about them (this member may be the bot itself)

So with this two information you can track the total number of users in your chat and who they are.

The basic strategy would be to store somewhere (like a database) the occurrences of joining and exiting of users from the group.

When a user join the chat store the object User to the storage. When a user exit the chat delete the object User from the storage.

Well then do the logic as you need.