From 76c0197ab73651b0ac5bc35b6f1c059c21d881fd Mon Sep 17 00:00:00 2001 From: coder2020official Date: Sun, 1 May 2022 16:11:00 +0500 Subject: [PATCH] Key for custom filters --- telebot/asyncio_filters.py | 8 ++++++++ telebot/custom_filters.py | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/telebot/asyncio_filters.py b/telebot/asyncio_filters.py index 312b290..c594d31 100644 --- a/telebot/asyncio_filters.py +++ b/telebot/asyncio_filters.py @@ -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. @@ -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. diff --git a/telebot/custom_filters.py b/telebot/custom_filters.py index 1bd80b3..abeffdd 100644 --- a/telebot/custom_filters.py +++ b/telebot/custom_filters.py @@ -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. @@ -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.