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
5c715dabc3
commit
4071ab9124
@ -306,7 +306,7 @@ If you want to add some built-in filter, you are welcome to add it in custom_fil
|
|||||||
|
|
||||||
Here is example of creating filter-class:
|
Here is example of creating filter-class:
|
||||||
|
|
||||||
```
|
```python
|
||||||
class IsAdmin(util.SimpleCustomFilter):
|
class IsAdmin(util.SimpleCustomFilter):
|
||||||
# Class will check whether the user is admin or creator in group or not
|
# Class will check whether the user is admin or creator in group or not
|
||||||
key='is_admin'
|
key='is_admin'
|
||||||
@ -314,14 +314,10 @@ class IsAdmin(util.SimpleCustomFilter):
|
|||||||
def check(message: telebot.types.Message):
|
def check(message: telebot.types.Message):
|
||||||
return bot.get_chat_member(message.chat.id,message.from_user.id).status in ['administrator','creator']
|
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.
|
# To register filter, you need to use method add_custom_filter.
|
||||||
|
|
||||||
bot.add_custom_filter(IsAdmin())
|
bot.add_custom_filter(IsAdmin())
|
||||||
|
|
||||||
|
|
||||||
# Now, you can use it in handler.
|
# Now, you can use it in handler.
|
||||||
|
|
||||||
@bot.message_handler(is_admin=True)
|
@bot.message_handler(is_admin=True)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user