mirror of
https://github.com/ijaric/voice_assistant.git
synced 2025-12-19 01:36:18 +00:00
feat: [#49] tg_bot
This commit is contained in:
5
src/bot_aiogram/tgbot/middlewares/__init__.py
Normal file
5
src/bot_aiogram/tgbot/middlewares/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from .environment import *
|
||||
|
||||
__all__ = [
|
||||
"EnvironmentMiddleware",
|
||||
]
|
||||
14
src/bot_aiogram/tgbot/middlewares/environment.py
Normal file
14
src/bot_aiogram/tgbot/middlewares/environment.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import typing
|
||||
|
||||
import aiogram.dispatcher.middlewares as dispatcher_middlewares
|
||||
|
||||
|
||||
class EnvironmentMiddleware(dispatcher_middlewares.LifetimeControllerMiddleware):
|
||||
skip_patterns = ["error", "update"]
|
||||
|
||||
def __init__(self, **kwargs: typing.Any):
|
||||
super().__init__()
|
||||
self.kwargs = kwargs
|
||||
|
||||
async def pre_process(self, obj: typing.Any, data: dict[typing.Any, typing.Any], *args: typing.Any):
|
||||
data.update(**self.kwargs)
|
||||
Reference in New Issue
Block a user