diff --git a/example/plugins/assets/video.mp4 b/example/plugins/assets/video.mp4 new file mode 100644 index 0000000..5b621bd Binary files /dev/null and b/example/plugins/assets/video.mp4 differ diff --git a/example/plugins/documents.py b/example/plugins/documents.py index 1169e5b..c298f92 100644 --- a/example/plugins/documents.py +++ b/example/plugins/documents.py @@ -25,6 +25,16 @@ async def _(msg, ctx): await ctx.reply("Document", attachments=[doc]) + # Video + with open(get_path(__file__, "assets/video.mp4"), "rb") as fh: + video = Attachment( + kind=AttachmentKind.VIDEO, + content=("beach.mp4", fh.read()), + title="Beach", + ) + + await ctx.reply("Video", attachments=[video]) + # Audio message with open(get_path(__file__, "assets/audio.ogg"), "rb") as fh: audio_message = Attachment( diff --git a/kutana/backends/telegram.py b/kutana/backends/telegram.py index 6c700b6..2e66f7b 100644 --- a/kutana/backends/telegram.py +++ b/kutana/backends/telegram.py @@ -135,7 +135,7 @@ def _make_attachment(self, raw_attachment, raw_attachment_kind): return Attachment( id=raw_attachment["file_id"], kind=AttachmentKind.DOCUMENT, - title=raw_attachment["file_name"], + title=raw_attachment.get("file_name"), raw=raw_attachment, get_file=partial(self._get_file, raw_attachment["file_id"]), ) @@ -153,7 +153,7 @@ def _make_attachment(self, raw_attachment, raw_attachment_kind): return Attachment( id=raw_attachment["file_id"], kind=AttachmentKind.VIDEO, - title=raw_attachment["file_name"], + title=raw_attachment.get("file_name"), raw=raw_attachment, get_file=partial(self._get_file, raw_attachment["file_id"]), )