22

I'm trying to obtain all users of a telegram group, I see the method getChatAdministrators, but I think the API doesn't have a method for obtaining all members.

I'm using telegram-bot-api of nodejs

whackamadoodle3000
  • 6,684
  • 4
  • 27
  • 44
juanjo Rodriguez
  • 221
  • 1
  • 2
  • 4

4 Answers4

24

Telegram Bot API:

What you are trying to archive is currently not possible using the bot api. I'm not sure about the nodejs api, but the official bot api (which your implementation is likely to use) currently doesn't allow getting specific information about all members.

What you can do though, is query how many users are currently in a group, using getchatmemberscount. And if you have the user id of one of the groups members, you can get further information about that user with the getchatmember function.

Telegram API:

With the Telegram API, you can control a "regular" user about how you would control a bot. It won't be apparent to any other users that your account is automated if you decide to use this API; in fact, the official telegram apps use it as their backend. However, you will need to sign up with your phone number just like you would with a regular account.

With this API, you can query all the chats the bot is in very easily using the getChats function. Then, you can query full chat info for a specific chat (including all users and their details) using getFullChat.

Community
  • 1
  • 1
Distjubo
  • 959
  • 6
  • 21
  • how to call the api? sorry i cant figure it out how to use the chat_id in the case of getFullChat – gabkov Sep 08 '21 at 14:11
4

You can extract all the members of any given group or channel(you need to be an admin for channel) using telethon, you can use telethon for that, you can find it here :- https://github.com/LonamiWebs/Telethon

Telethon extracts all the members of an given group and saves it in a SQLite database.

Smitk
  • 91
  • 1
  • 7
  • How? Maybe an example using the Telethon would be nice. Or at least point to the exact part in the docs, instead of the whole repository. Also, this doesn't answer the question using solely a bot. The telethon has to login as a normal telegram user. – KhoPhi Feb 14 '22 at 18:00
  • Thanks for idea - I've used this code with Telethon: https://stackoverflow.com/a/68047452/2097494 – PokatilovArt Feb 25 '23 at 10:46
3

Telegram Bot API does not provide such functionality, the only way to do this efficiently is by using userbot (bot running under regular Telegram account).

Jack'lul
  • 383
  • 1
  • 8
2

Have you solved the problem? I use the GetChatMemberCount method of the telegram bot api to get the membercount of the group. And I can also use the bot api to get the user information who send message to the group.I doubt that is there any other way to get the membercount without the bot api.

EvanLee
  • 49
  • 5