You've already forked Travel-Agent
feat: Added ability to upload video and voice messages as notes
This commit is contained in:
+31
-4
@@ -70,7 +70,12 @@ async def create_note_file_id(message: Message, state: FSMContext):
|
|||||||
|
|
||||||
return
|
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
|
return
|
||||||
|
|
||||||
if message.photo is not None:
|
if message.photo is not None:
|
||||||
@@ -80,8 +85,6 @@ async def create_note_file_id(message: Message, state: FSMContext):
|
|||||||
file_name="photo",
|
file_name="photo",
|
||||||
)
|
)
|
||||||
|
|
||||||
# await message.answer_photo(message.photo[-1].file_id)
|
|
||||||
|
|
||||||
elif message.document is not None:
|
elif message.document is not None:
|
||||||
await state.update_data(
|
await state.update_data(
|
||||||
file_type="document",
|
file_type="document",
|
||||||
@@ -89,7 +92,19 @@ async def create_note_file_id(message: Message, state: FSMContext):
|
|||||||
file_name=message.document.file_name,
|
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()
|
data = await state.get_data()
|
||||||
|
|
||||||
@@ -211,6 +226,18 @@ async def travel_notesend_callback(
|
|||||||
reply_to_message_id=callback.message.message_id,
|
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()
|
await callback.answer()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -170,6 +170,10 @@ def notes_keyboard(notes, page: int, pages: int, travel_id: int):
|
|||||||
for note in notes[start_index:end_index]:
|
for note in notes[start_index:end_index]:
|
||||||
if note.file_type == "photo":
|
if note.file_type == "photo":
|
||||||
button_text = f"Photo ID: {note.id}"
|
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:
|
else:
|
||||||
button_text = note.file_name
|
button_text = note.file_name
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -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."
|
INVALID_DATE_END = "End date can't be earlier or equal to start date."
|
||||||
LOCATION_ADDED = "✅ Location added"
|
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"
|
DELETED_TRAVEL = "✅ Travel deleted"
|
||||||
TRAVELS = "📃 <b>Travels:</b>\n<i>👑 - owner</i>"
|
TRAVELS = "📃 <b>Travels:</b>\n<i>👑 - owner</i>"
|
||||||
|
|||||||
Reference in New Issue
Block a user