feat: Added ability to upload video and voice messages as notes

This commit is contained in:
ITQ
2024-03-26 09:06:26 +03:00
parent 37101629b5
commit 1d8ce5844e
3 changed files with 36 additions and 5 deletions
+31 -4
View File
@@ -70,7 +70,12 @@ async def create_note_file_id(message: Message, state: FSMContext):
return
if message.photo is None and message.document is None:
if (
message.photo is None
and message.document is None
and message.video is None
and message.voice is None
):
return
if message.photo is not None:
@@ -80,8 +85,6 @@ async def create_note_file_id(message: Message, state: FSMContext):
file_name="photo",
)
# await message.answer_photo(message.photo[-1].file_id)
elif message.document is not None:
await state.update_data(
file_type="document",
@@ -89,7 +92,19 @@ async def create_note_file_id(message: Message, state: FSMContext):
file_name=message.document.file_name,
)
# await message.answer_document(message.document.file_id)
elif message.video is not None:
await state.update_data(
file_type="video",
file_id=message.video.file_id,
file_name="video",
)
elif message.voice is not None:
await state.update_data(
file_type="voice",
file_id=message.voice.file_id,
file_name="voice",
)
data = await state.get_data()
@@ -211,6 +226,18 @@ async def travel_notesend_callback(
reply_to_message_id=callback.message.message_id,
)
elif note.file_type == "video":
await callback.message.answer_video(
note.file_id,
reply_to_message_id=callback.message.message_id,
)
elif note.file_type == "voice":
await callback.message.answer_voice(
note.file_id,
reply_to_message_id=callback.message.message_id,
)
await callback.answer()
+4
View File
@@ -170,6 +170,10 @@ def notes_keyboard(notes, page: int, pages: int, travel_id: int):
for note in notes[start_index:end_index]:
if note.file_type == "photo":
button_text = f"Photo ID: {note.id}"
elif note.file_type == "video":
button_text = f"Video ID: {note.id}"
elif note.file_type == "voice":
button_text = f"Voice ID: {note.id}"
else:
button_text = note.file_name
+1 -1
View File
@@ -41,7 +41,7 @@ ENTER_LOCATION_DATE_END = "Enter location end datetime(in UTC) in this format:\n
INVALID_DATE_END = "End date can't be earlier or equal to start date."
LOCATION_ADDED = "✅ Location added"
ADD_NOTE = "✏️ Send me file or photo to add note.\n<i>Enter /cancel to cancel creating.</i>"
ADD_NOTE = "✏️ Send me file, photo, video or voice nessage to add note.\n<i>Enter /cancel to cancel creating.</i>"
DELETED_TRAVEL = "✅ Travel deleted"
TRAVELS = "📃 <b>Travels:</b>\n<i>👑 - owner</i>"