43 lines
1.5 KiB
Python
43 lines
1.5 KiB
Python
|
# Импорт модулей стандартной библиотеки
|
||
|
from random import choice
|
||
|
|
||
|
# Импорт сторонних модулей
|
||
|
from aiogram import F
|
||
|
from aiogram.filters import CommandStart
|
||
|
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
|
||
|
from aiogram.types import Message, FSInputFile
|
||
|
|
||
|
# Импорт модулей приложения
|
||
|
from . import logger, db, dp
|
||
|
from .actions import *
|
||
|
|
||
|
|
||
|
@dp.message(CommandStart())
|
||
|
async def command_start_handler(message: Message) -> None:
|
||
|
msg = '👋🏻 Привет\\!\n\nОтправь сообщение боту и 🍪 *Печенька* в скором времени ответит тебе 🤭'
|
||
|
|
||
|
actions = [
|
||
|
[InlineKeyboardButton(text='🎁 Сделать подарок', callback_data='action_gift')],
|
||
|
[InlineKeyboardButton(text='💩 Сделать пакость', callback_data='action_poo')],
|
||
|
[InlineKeyboardButton(text='🤤 Погладить', callback_data='action_caress')],
|
||
|
]
|
||
|
|
||
|
await message.answer_photo(
|
||
|
photo=FSInputFile(path='./assets/hello.jpg'),
|
||
|
caption=msg,
|
||
|
reply_markup=InlineKeyboardMarkup(inline_keyboard=[choice(actions)]),
|
||
|
)
|
||
|
|
||
|
|
||
|
@dp.message()
|
||
|
async def echo_handler(message: Message) -> None:
|
||
|
telegram_id = message.from_user.id
|
||
|
msg = message.text
|
||
|
|
||
|
# logger.info('Добавляем запрос от пользователя ...')
|
||
|
status = db.add_issue(telegram_id, msg)
|
||
|
|
||
|
msg = status['message'].replace('.', '\\.')
|
||
|
|
||
|
await message.answer(text=msg)
|