Get all users of telegram group
Asked Answered
S

4

24

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

Sudd answered 26/6, 2018 at 19:21 Comment(0)
D
25

Telegram Bot API:

What you are trying to achieve 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.

Dahna answered 26/6, 2018 at 20:14 Comment(1)
how to call the api? sorry i cant figure it out how to use the chat_id in the case of getFullChatTurley
E
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.

Eveevection answered 12/7, 2018 at 14:1 Comment(2)
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.Shandashandee
Thanks for idea - I've used this code with Telethon: https://mcmap.net/q/583017/-how-to-get-all-users-in-a-telegram-channel-using-telethonErivan
D
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).

Demonography answered 26/6, 2018 at 20:8 Comment(0)
P
2

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 sent message to the group. I doubt that is there any other way to get the membercount without the bot API.

Peskoff answered 11/7, 2018 at 9:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.