mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 10:11:52 +00:00
Allow to cancel event from the Middleware.on_pre_process_<event type>
This commit is contained in:
parent
163ca0d53a
commit
856b9e864f
1 changed files with 5 additions and 1 deletions
|
|
@ -60,7 +60,11 @@ class Handler:
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
if self.middleware_key:
|
if self.middleware_key:
|
||||||
|
try:
|
||||||
await self.dispatcher.middleware.trigger(f"pre_process_{self.middleware_key}", args)
|
await self.dispatcher.middleware.trigger(f"pre_process_{self.middleware_key}", args)
|
||||||
|
except CancelHandler: # Allow to cancel current event
|
||||||
|
return results
|
||||||
|
|
||||||
for filters, handler in self.handlers:
|
for filters, handler in self.handlers:
|
||||||
if await check_filters(filters, args):
|
if await check_filters(filters, args):
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue