Telegram.Bot icon indicating copy to clipboard operation
Telegram.Bot copied to clipboard

How to get a list of chats which my bot is administrator on them?

Open webiox opened this issue 9 years ago • 11 comments

Hi buddy... I wanna know that if my bot added as an administrator to a group or private chat or not. Is there any way to get chat_id of a group, super group or private channels that I've never sent any message to them? Is there any way to get chat_id from a chat join URL or something like that? Is it possible to get a list of chats which my bot is administrator on them?

webiox avatar Aug 27 '17 06:08 webiox

So. First, if your bot is added to a group, it will receive an update containing a message of type MessageType.ServiceMessage with your bot as the new chat member. You can get your bots status in a group by using GetChatMemberAsync with the chats id and the one of your bot. AFAIK you cannot get the chat id from a link, and no, you have to keep track of the groups your bot is admin in yourself.

Olfi01 avatar Aug 27 '17 06:08 Olfi01

thank you @Olfi01 for your prompt response, but the main problem is my bot is admin on over 5000 active channels and groups so it receives a lot of updates per second! When a group or channel is private, I can't realize which update is related to my bot new chat member to get the new chat_id. and also, I can't search among received updates archive to realize it, because I don't have any specific key like channels username to inquiry.

webiox avatar Aug 27 '17 06:08 webiox

Well, you will have to look at every update, whether you have that group in your database or not and if not, add it. I'm afraid the telegram bot api does not offer a method for that.

Olfi01 avatar Aug 27 '17 06:08 Olfi01

@Olfi01 Thank you pal...

webiox avatar Aug 27 '17 06:08 webiox

No problem, feel free to ask anything you want or reopen this issue if you need additional information!

Olfi01 avatar Aug 27 '17 07:08 Olfi01

How to check if my bot is admin on a channel or not without sending message? Obviously i have the channel username

github-repos avatar Feb 05 '18 13:02 github-repos

so there is not a function to get all chats my bot is administrator of, right?

johnbalvin avatar Aug 07 '19 22:08 johnbalvin

There isn't

matteocontrini avatar Aug 08 '19 07:08 matteocontrini

So. First, if your bot is added to a group, it will receive an update containing a message of type MessageType.ServiceMessage with your bot as the new chat member. You can get your bots status in a group by using GetChatMemberAsync with the chats id and the one of your bot. AFAIK you cannot get the chat id from a link, and no, you have to keep track of the groups your bot is admin in yourself.

If someone adds my BOT to Channel as an admin Will I get notified! As I am not receiving any thing! While Someone adds My BOT to group an OnUpdate fires and I am receiving MessageType.ChatCreated. But not with Channels. IS there anything that is missing from my end to check! TIA

patelonline avatar Feb 16 '20 11:02 patelonline

So. First, if your bot is added to a group, it will receive an update containing a message of type MessageType.ServiceMessage with your bot as the new chat member. You can get your bots status in a group by using GetChatMemberAsync with the chats id and the one of your bot. AFAIK you cannot get the chat id from a link, and no, you have to keep track of the groups your bot is admin in yourself.

Can you show me how you would handle this using Telegraf.js?

Mikiyas721 avatar Apr 05 '22 05:04 Mikiyas721

So. First, if your bot is added to a group, it will receive an update containing a message of type MessageType.ServiceMessage with your bot as the new chat member. You can get your bots status in a group by using GetChatMemberAsync with the chats id and the one of your bot. AFAIK you cannot get the chat id from a link, and no, you have to keep track of the groups your bot is admin in yourself.

If someone adds my BOT to Channel as an admin Will I get notified! As I am not receiving any thing! While Someone adds My BOT to group an OnUpdate fires and I am receiving MessageType.ChatCreated. But not with Channels. IS there anything that is missing from my end to check! TIA

Did you find anything for channel, bc I'm also facing same issue?

ErShakirAnsari avatar Feb 07 '24 06:02 ErShakirAnsari