Fix filters.

This commit is contained in:
Alex Root Junior 2018-11-24 22:12:20 +02:00
parent c153fcfe8d
commit 2e2d9ea433
3 changed files with 5 additions and 7 deletions

View file

@ -393,11 +393,10 @@ class ExceptionsFilter(BoundFilter):
key = 'exception'
def __init__(self, dispatcher, exception):
super().__init__(dispatcher)
def __init__(self, exception):
self.exception = exception
async def check(self, dispatcher, update, exception):
async def check(self, update, exception):
try:
raise exception
except self.exception:

View file

@ -3,7 +3,6 @@ import inspect
import typing
from ..handler import Handler
from ...types.base import TelegramObject
class FilterNotPassed(Exception):
@ -140,8 +139,8 @@ class AbstractFilter(abc.ABC):
"""
pass
async def __call__(self, obj: TelegramObject) -> bool:
return await self.check(obj)
async def __call__(self, *args) -> bool:
return await self.check(*args)
def __invert__(self):
return NotFilter(self)

View file

@ -46,7 +46,7 @@ class ThrottlingMiddleware(BaseMiddleware):
self.prefix = key_prefix
super(ThrottlingMiddleware, self).__init__()
async def on_process_message(self, message: types.Message):
async def on_process_message(self, message: types.Message, data: dict):
"""
This handler is called when dispatcher receives a message