finos / symphony-bdk-python

Symphony Python Bot Development Kit (BDK)
https://symphony-bdk-python.finos.org/
Apache License 2.0
31 stars 34 forks source link

Gif images as attachments don't move/update #262

Closed dky closed 2 years ago

dky commented 2 years ago

I'm running into an issue where if I attach a gif image as a file using the following method:

with open("image.gif", "rb") as file:
  await bdk.messages().send_message(stream_id, Message(content="Hello", attachments=[file]))

The attachment shows up in a room as an image however the gif doesn't actively update. Am I missing a param that I should add to make the gif be interactive?

I've been reading the docs for this:

https://symphony-bdk-python.finos.org/_autosummary/symphony.bdk.core.service.message.model.Message.html

And it's not clear to me if there's potentially a preview flag that I'm missing. Any help would be appreciated!

Thanks!

symphony-youri commented 2 years ago

Hi @dky,

Indeed the preview should help do display the animated GIF. For instance:

with open("giphy.gif", "rb") as file, \
        open("giphy.gif", "rb") as filePreview:
    message = Message(content="<messageML>Hello, World!</messageML>",
                      attachments=[(file1, filePreview)])
    await message_service.send_message(stream_id_1, message)

Here we sent a tuple with one attachment and one preview (https://symphony-bdk-python.finos.org/_autosummary/symphony.bdk.core.service.message.message_service.MessageService.html#symphony.bdk.core.service.message.message_service.MessageService.send_message). Both are going to be read and closed so even if the image is small and we would like to send the same one for attachment and preview, we open it twice.

dky commented 2 years ago

Thanks @symphony-youri for showing me the example of how to use preview! I was looking at the signature and stumped for a bit. Glad I wasn't too far off in reading the docs.