Update README.md

This commit is contained in:
_run 2021-09-12 20:40:31 +05:00 committed by GitHub
parent 43d2d8583e
commit 5c715dabc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 0 deletions

View File

@ -304,6 +304,28 @@ Example of [filtering by text](https://github.com/eternnoir/pyTelegramBotAPI/blo
If you want to add some built-in filter, you are welcome to add it in custom_filters.py file.
Here is example of creating filter-class:
```
class IsAdmin(util.SimpleCustomFilter):
# Class will check whether the user is admin or creator in group or not
key='is_admin'
@staticmethod
def check(message: telebot.types.Message):
return bot.get_chat_member(message.chat.id,message.from_user.id).status in ['administrator','creator']
# To register filter, you need to use method add_custom_filter.
bot.add_custom_filter(IsAdmin())
# Now, you can use it in handler.
@bot.message_handler(is_admin=True)
```
#### TeleBot
```python