Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Telegram check if user is admin

I am using the telegram bot api to make a bot. I have some commands that can only be sent from admins. Like kick and ban commands. How do I check if the sender is an admin or not? I am using the python-telegram-bot api. I do not want everyone to be able to ban members.

like image 945
ICanKindOfCode Avatar asked Jan 07 '18 11:01

ICanKindOfCode


People also ask

How do you check if someone is an admin on Telegram?

The admin status is stored under Telegram. ChatMember. status . It is documented here.

How can I see the admin list in Telegram group?

For get a list of administrators (except other bots) in a channel, you can use the getChatAdministrators method. Remember that the bot must be admin of the channel. In no way you can get the administrators of a channel without be an administrator.

Can an admin make another person admin in Telegram?

Telegram chats can have an unlimited number of administrators. To add an admin, you don't have to quit being an admin yourself. However, if you don't want to be a group admin any longer, you can assign the administrator privileges to someone else.


2 Answers

You can use getChatMember method. See following instance:

Awesome Telegram Bot

like image 84
Sean Avatar answered Sep 21 '22 12:09

Sean


I have found after searching a bit. The admin status is stored under Telegram.ChatMember.status. It is documented here. It is used by bot.get_chat_member(chat_id, user_id). And then getting status in it.

like image 26
ICanKindOfCode Avatar answered Sep 18 '22 12:09

ICanKindOfCode