mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
commit
f2202b44fe
@ -3140,10 +3140,10 @@ class TeleBot:
|
|||||||
filter_check = self.custom_filters.get(message_filter)
|
filter_check = self.custom_filters.get(message_filter)
|
||||||
if not filter_check:
|
if not filter_check:
|
||||||
return False
|
return False
|
||||||
elif isinstance(filter_value, util.SimpleCustomFilter):
|
elif isinstance(filter_check, util.SimpleCustomFilter):
|
||||||
return filter_value == filter_check.check(message)
|
return filter_value == filter_check.check(message)
|
||||||
elif isinstance(filter_value, util.AdvancedCustomFilter):
|
elif isinstance(filter_check, util.AdvancedCustomFilter):
|
||||||
return filter_check.check(message,filter_value)
|
return filter_check.check(message, filter_value)
|
||||||
else:
|
else:
|
||||||
logger.error("Custom filter: wrong type. Should be SimpleCustomFilter or AdvancedCustomFilter.")
|
logger.error("Custom filter: wrong type. Should be SimpleCustomFilter or AdvancedCustomFilter.")
|
||||||
return False
|
return False
|
||||||
|
@ -5,6 +5,7 @@ import string
|
|||||||
import threading
|
import threading
|
||||||
import traceback
|
import traceback
|
||||||
from typing import Any, Callable, List, Dict, Optional, Union
|
from typing import Any, Callable, List, Dict, Optional, Union
|
||||||
|
from abc import ABC
|
||||||
|
|
||||||
# noinspection PyPep8Naming
|
# noinspection PyPep8Naming
|
||||||
import queue as Queue
|
import queue as Queue
|
||||||
@ -457,20 +458,20 @@ def webhook_google_functions(bot, request):
|
|||||||
return 'Bot ON'
|
return 'Bot ON'
|
||||||
|
|
||||||
|
|
||||||
class SimpleCustomFilter:
|
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 bool.
|
Accepts only bool.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def check(message):
|
def check(self, message):
|
||||||
"""
|
"""
|
||||||
Perform a check.
|
Perform a check.
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class AdvancedCustomFilter:
|
class AdvancedCustomFilter(ABC):
|
||||||
"""
|
"""
|
||||||
Simple Custom Filter base class.
|
Simple Custom Filter base class.
|
||||||
Create child class with check() method.
|
Create child class with check() method.
|
||||||
@ -479,8 +480,8 @@ class AdvancedCustomFilter:
|
|||||||
text: Filter value given in handler
|
text: Filter value given in handler
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def check(message, text):
|
def check(self, message, text):
|
||||||
"""
|
"""
|
||||||
Perform a check.
|
Perform a check.
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user