3

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

Thiyaga B
  • 971
  • 1
  • 9
  • 26
  • This has been answered here. [Check message sender api](https://stackoverflow.com/questions/48387330/telegram-bot-can-we-identify-if-message-is-from-group-admin) – Dhnesh Dhingra Aug 30 '18 at 09:43

3 Answers3

7

When you use getUpdates, you can see .message.chat.type is group or not.

And then use getChatMember, .result.status should be administrator or creator.

Sean Wei
  • 7,433
  • 1
  • 19
  • 39
3

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

jh0ker
  • 158
  • 5
-1

No. You need to hardcode user id in your source and compare if user id in admin-ids array.

lov3catch
  • 133
  • 1
  • 2
  • 11