Skip to content

Commit

Permalink
Merge pull request #1526 from coder2020official/master
Browse files Browse the repository at this point in the history
Key for custom filters
  • Loading branch information
Badiboy authored May 1, 2022
2 parents 7d9658b + 76c0197 commit 617c990
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions telebot/asyncio_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ class SimpleCustomFilter(ABC):
Simple Custom Filter base class.
Create child class with check() method.
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):
"""
Perform a check.
Expand All @@ -26,8 +30,12 @@ class AdvancedCustomFilter(ABC):
Accepts two parameters, returns bool: True - filter passed, False - filter failed.
message: Message class
text: Filter value given in handler
Child classes should have .key property.
"""

key: str = None

async def check(self, message, text):
"""
Perform a check.
Expand Down
8 changes: 8 additions & 0 deletions telebot/custom_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ class SimpleCustomFilter(ABC):
Simple Custom Filter base class.
Create child class with check() method.
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):
"""
Perform a check.
Expand All @@ -28,8 +32,12 @@ class AdvancedCustomFilter(ABC):
Accepts two parameters, returns bool: True - filter passed, False - filter failed.
message: Message class
text: Filter value given in handler
Child classes should have .key property.
"""

key: str = None

def check(self, message, text):
"""
Perform a check.
Expand Down

0 comments on commit 617c990

Please sign in to comment.