Reputation: 712
I've been using a Telegram BOT to send notifications for a group, and for users.
I already know i can get Chat ID by receiving a message from the user on my bot, using getUpdates.
I also know i can get Group ID using the same method...
But what i really need is: There is three users in my group.
Is it possible to get this third user his ID? PS: I am the group owner, and also added my bot as Admin...
The third user is a normal user. Can someone help me?
Thanks!
Upvotes: 5
Views: 9818
Reputation: 11
The GetChatAdministrators method in the go-telegram-bot-api package only retrieves information about chat administrators, not all chat members. Unfortunately, there is no direct method available in the Telegram Bot API to retrieve information about all chat members.
As a bot, your access to chat member information is limited. You can only retrieve information about the chat members who have interacted with your bot by sending messages or interacting with bot commands.
If you need information about all members in a chat, including non-interacting members, you would require access to the Telegram API through the Telegram Client API (MTProto). However, please note that using the Telegram Client API requires more complex setup and authentication.
If you're specifically looking to retrieve user IDs of chat members who have interacted with your bot, you can make use of the update.Message.From.ID field in the received updates. This will give you the user ID of the member who sent the message to your bot.
Upvotes: 0
Reputation: 5399
That's not possible with the official Telegram Bot API.
Possible Workarounds:
Hold a list of your own. If a user is joining (new_chat_member), leaving (left_chat_member), somebody is sending a message in the group, and so on. Check Message for more information.
Check if a user is a member of the group with getChatMember.
Also may be helpful: getChatMembersCount and getChatAdministrators
Upvotes: 2