Skip to content

Commit a5fb9f1

Browse files
committed
feat: identify documents in replies
1 parent 880d8c5 commit a5fb9f1

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/bot/routers/printing/printing.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from aiogram.types import (
1313
BufferedInputFile,
1414
CallbackQuery,
15+
ContentType,
1516
InlineKeyboardButton,
1617
InlineKeyboardMarkup,
1718
Message,
@@ -79,9 +80,9 @@ async def document_handler(message: Message, state: FSMContext, bot: Bot):
7980
if e.response.status_code == 400:
8081
await message.answer(
8182
f"Unfortunately, we cannot print this file yet\n"
82-
f"because of {html.bold(html.quote(e.response.json()["detail"]))}\n\n"
83+
f"because of {html.bold(html.quote(e.response.json()['detail']))}\n\n"
8384
f"Please, send a file of a supported type:\n"
84-
f"{html.blockquote(".doc\n.docx\n.png\n.txt\n.jpg\n.md\n.bmp\n.xlsx\n.xls\n.odt\n.ods")}\n"
85+
f"{html.blockquote('.doc\n.docx\n.png\n.txt\n.jpg\n.md\n.bmp\n.xlsx\n.xls\n.odt\n.ods')}\n"
8586
f"or convert the file to PDF manually and try again."
8687
)
8788
return
@@ -134,7 +135,7 @@ async def cancel_print_configuration_handler(callback: CallbackQuery, state: FSM
134135
try:
135136
if isinstance(callback.message, Message):
136137
await callback.message.edit_caption(
137-
caption=f"{callback.message.caption}\n\n{html.bold('You\'ve cancelled this print work 🤷‍♀️')}"
138+
caption=f"{callback.message.caption}\n\n{html.bold("You've cancelled this print work 🤷‍♀️")}"
138139
)
139140
except aiogram.exceptions.TelegramBadRequest:
140141
pass
@@ -148,7 +149,7 @@ class MenuDuringPrintingCallback(CallbackData, prefix="menu_during_printing"):
148149

149150
@router.callback_query(PrintWork.settings_menu, MenuCallback.filter(F.menu == "confirm"))
150151
@flags.chat_action("typing")
151-
async def start_print_handler(callback: CallbackQuery, state: FSMContext, bot: Bot):
152+
async def start_print_handler(callback: CallbackQuery, state: FSMContext):
152153
await callback.answer()
153154
await state.set_state(PrintWork.printing)
154155

@@ -281,3 +282,11 @@ async def cancel_print_handler(callback: CallbackQuery, callback_data: MenuDurin
281282
await callback.message.edit_caption(caption=caption)
282283
except (aiogram.exceptions.TelegramBadRequest, KeyError):
283284
pass
285+
286+
287+
@router.message(
288+
F.reply_to_message,
289+
lambda message: message.reply_to_message.content_type in (ContentType.DOCUMENT, ContentType.PHOTO),
290+
)
291+
async def any_message_handler(message: Message, state: FSMContext, bot: Bot):
292+
await document_handler(message.reply_to_message, state, bot)

0 commit comments

Comments
 (0)