mirror of
https://github.com/ijaric/voice_assistant.git
synced 2025-12-18 15:46:17 +00:00
feat: [#49] tg_bot
This commit is contained in:
5
src/bot_aiogram/tgbot/__init__.py
Normal file
5
src/bot_aiogram/tgbot/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from .settings import Settings
|
||||
|
||||
__all__ = [
|
||||
"Settings",
|
||||
]
|
||||
0
src/bot_aiogram/tgbot/filters/__init__.py
Normal file
0
src/bot_aiogram/tgbot/filters/__init__.py
Normal file
9
src/bot_aiogram/tgbot/handlers/__init__.py
Normal file
9
src/bot_aiogram/tgbot/handlers/__init__.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from .echo import *
|
||||
from .user import *
|
||||
from .voice import *
|
||||
|
||||
__all__ = [
|
||||
"register_echo",
|
||||
"register_user",
|
||||
"register_voice_response",
|
||||
]
|
||||
11
src/bot_aiogram/tgbot/handlers/echo.py
Normal file
11
src/bot_aiogram/tgbot/handlers/echo.py
Normal file
@@ -0,0 +1,11 @@
|
||||
import aiogram
|
||||
|
||||
|
||||
async def bot_echo(message: aiogram.types.Message):
|
||||
text = ["Эхо без состояния.", "Сообщение:", message.text]
|
||||
|
||||
await message.answer("\n".join(text))
|
||||
|
||||
|
||||
def register_echo(dp: aiogram.Dispatcher):
|
||||
dp.register_message_handler(bot_echo)
|
||||
9
src/bot_aiogram/tgbot/handlers/user.py
Normal file
9
src/bot_aiogram/tgbot/handlers/user.py
Normal file
@@ -0,0 +1,9 @@
|
||||
import aiogram
|
||||
|
||||
|
||||
async def user_start(message: aiogram.types.Message):
|
||||
await message.reply("Hello, user! Send me a voice message and I'll try to recognize it and answer you.")
|
||||
|
||||
|
||||
def register_user(dp: aiogram.Dispatcher):
|
||||
dp.register_message_handler(user_start, commands=["start"], state="*")
|
||||
0
src/bot_aiogram/tgbot/keyboards/__init__.py
Normal file
0
src/bot_aiogram/tgbot/keyboards/__init__.py
Normal file
0
src/bot_aiogram/tgbot/keyboards/inline.py
Normal file
0
src/bot_aiogram/tgbot/keyboards/inline.py
Normal file
0
src/bot_aiogram/tgbot/keyboards/reply.py
Normal file
0
src/bot_aiogram/tgbot/keyboards/reply.py
Normal file
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)
|
||||
0
src/bot_aiogram/tgbot/misc/__init__.py
Normal file
0
src/bot_aiogram/tgbot/misc/__init__.py
Normal file
0
src/bot_aiogram/tgbot/misc/states.py
Normal file
0
src/bot_aiogram/tgbot/misc/states.py
Normal file
0
src/bot_aiogram/tgbot/models/__init__.py
Normal file
0
src/bot_aiogram/tgbot/models/__init__.py
Normal file
0
src/bot_aiogram/tgbot/services/__init__.py
Normal file
0
src/bot_aiogram/tgbot/services/__init__.py
Normal file
Reference in New Issue
Block a user