Update custom_filters.py

This commit is contained in:
_run 2021-09-22 22:37:18 +05:00
parent c6ff9b07df
commit 9c86ed623d
1 changed files with 16 additions and 0 deletions

View File

@ -130,3 +130,19 @@ class LanguageFilter(AdvancedCustomFilter):
if type(text) is list:return message.from_user.language_code in text
else: return message.from_user.language_code == text
class IsAdminFilter(SimpleCustomFilter):
"""
Check whether the user is administrator / owner of the chat.
Example:
@bot.message_handler(chat_types=['supergroup'], is_chat_admin=True)
"""
key = 'is_chat_admin'
def __init__(self, bot):
self._bot = bot
def check(self, message):
return self._bot.get_chat_member(message.chat.id, message.from_user.id).status in ['creator', 'administrator']