mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-06 07:50:32 +00:00
Fix filtering skip_patterns (#868)
* Fix filtering skip_patterns * cache skip actions
This commit is contained in:
parent
016a8d3c6c
commit
d5654068b1
1 changed files with 14 additions and 1 deletions
|
|
@ -110,6 +110,19 @@ class LifetimeControllerMiddleware(BaseMiddleware):
|
|||
# TODO: Rename class
|
||||
|
||||
skip_patterns = None
|
||||
_skip_actions = None
|
||||
|
||||
@property
|
||||
def skip_actions(self):
|
||||
if self._skip_actions is None:
|
||||
self._skip_actions = []
|
||||
if self.skip_patterns:
|
||||
self._skip_actions.extend([
|
||||
f"pre_process_{item}",
|
||||
f"process_{item}",
|
||||
f"post_process_{item}",
|
||||
])
|
||||
return self._skip_actions
|
||||
|
||||
async def pre_process(self, obj, data, *args):
|
||||
pass
|
||||
|
|
@ -118,7 +131,7 @@ class LifetimeControllerMiddleware(BaseMiddleware):
|
|||
pass
|
||||
|
||||
async def trigger(self, action, args):
|
||||
if self.skip_patterns is not None and any(item in action for item in self.skip_patterns):
|
||||
if action in self.skip_actions:
|
||||
return False
|
||||
|
||||
obj, *args, data = args
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue