1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Merge pull request #1526 from coder2020official/master

Key for custom filters
This commit is contained in:
Badiboy 2022-05-01 17:01:37 +03:00 committed by GitHub
commit 617c990994
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -10,8 +10,12 @@ class SimpleCustomFilter(ABC):
Simple Custom Filter base class. Simple Custom Filter base class.
Create child class with check() method. Create child class with check() method.
Accepts only message, returns bool value, that is compared with given in handler. Accepts only message, returns bool value, that is compared with given in handler.
Child classes should have .key property.
""" """
key: str = None
async def check(self, message): async def check(self, message):
""" """
Perform a check. Perform a check.
@ -26,8 +30,12 @@ class AdvancedCustomFilter(ABC):
Accepts two parameters, returns bool: True - filter passed, False - filter failed. Accepts two parameters, returns bool: True - filter passed, False - filter failed.
message: Message class message: Message class
text: Filter value given in handler text: Filter value given in handler
Child classes should have .key property.
""" """
key: str = None
async def check(self, message, text): async def check(self, message, text):
""" """
Perform a check. Perform a check.

View File

@ -12,8 +12,12 @@ class SimpleCustomFilter(ABC):
Simple Custom Filter base class. Simple Custom Filter base class.
Create child class with check() method. Create child class with check() method.
Accepts only message, returns bool value, that is compared with given in handler. Accepts only message, returns bool value, that is compared with given in handler.
Child classes should have .key property.
""" """
key: str = None
def check(self, message): def check(self, message):
""" """
Perform a check. Perform a check.
@ -28,8 +32,12 @@ class AdvancedCustomFilter(ABC):
Accepts two parameters, returns bool: True - filter passed, False - filter failed. Accepts two parameters, returns bool: True - filter passed, False - filter failed.
message: Message class message: Message class
text: Filter value given in handler text: Filter value given in handler
Child classes should have .key property.
""" """
key: str = None
def check(self, message, text): def check(self, message, text):
""" """
Perform a check. Perform a check.