mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Update README.md
This commit is contained in:
parent
43d2d8583e
commit
5c715dabc3
22
README.md
22
README.md
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user