I have added my bot to a group chat, now for few commands I need to give access only to the group admin, so is it possible to identify if the message sender is admin of the group? I am using python-telegram-bot library
It is absolutely possible. You can use the getChatAdministrators
API method (returns a list of ChatMember
) to get a list of admins for a chat, or the getChatMember
API method (returns a single ChatMember
) to get the admin status of a single user.
An efficient method to solve this problem is described here: https://github.com/python-telegram-bot/python-telegram-bot/wiki/Code-snippets#cached-telegram-group-administrator-check