The entire database has been changed to PostgresSQL. The entire code has been updated.
This commit is contained in:
50
app/telegram/handlers/common.py
Normal file
50
app/telegram/handlers/common.py
Normal file
@@ -0,0 +1,50 @@
|
||||
import logging.config
|
||||
|
||||
from aiogram import Router
|
||||
from aiogram.fsm.context import FSMContext
|
||||
from aiogram.types import Message
|
||||
|
||||
from logger_helper.logger_helper import LOGGING_CONFIG
|
||||
|
||||
logging.config.dictConfig(LOGGING_CONFIG)
|
||||
logger = logging.getLogger("common")
|
||||
|
||||
router_common = Router(name="common")
|
||||
|
||||
|
||||
@router_common.message()
|
||||
async def unknown_message(message: Message, state: FSMContext) -> None:
|
||||
"""
|
||||
Handle unexpected or unrecognized messages.
|
||||
Clears FSM state and informs the user about available commands.
|
||||
|
||||
Args:
|
||||
message (types.Message): Incoming message object.
|
||||
state (FSMContext): Current FSM context.
|
||||
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
try:
|
||||
await message.answer(
|
||||
text="Извините, я вас не понял. "
|
||||
"Пожалуйста, используйте одну из следующих команд:\n"
|
||||
"/start - Запустить бота\n"
|
||||
"/profile - Профиль\n"
|
||||
"/bybit - Панель Bybit\n"
|
||||
"/help - Получить помощь\n"
|
||||
)
|
||||
logger.debug(
|
||||
"Received unknown message from user %s: %s",
|
||||
message.from_user.id,
|
||||
message.text,
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(
|
||||
"Error handling unknown message for user %s: %s", message.from_user.id, e
|
||||
)
|
||||
await message.answer(
|
||||
text="Произошла ошибка при обработке вашего сообщения. Пожалуйста, попробуйте позже."
|
||||
)
|
||||
finally:
|
||||
await state.clear()
|
Reference in New Issue
Block a user