From bd490c1d1972e5a375214347a550fd7a7c2a0101 Mon Sep 17 00:00:00 2001 From: Goffi Date: Wed, 26 Feb 2020 22:03:15 +0100 Subject: [PATCH] primitivus (chat) Q&D way to see attachments --- sat_frontends/primitivus/chat.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sat_frontends/primitivus/chat.py b/sat_frontends/primitivus/chat.py index 3ca11ce3..5df6254f 100644 --- a/sat_frontends/primitivus/chat.py +++ b/sat_frontends/primitivus/chat.py @@ -18,6 +18,7 @@ # along with this program. If not, see . from functools import total_ordering +from pathlib import Path import bisect import urwid from urwid_satext import sat_widgets @@ -442,6 +443,20 @@ class Chat(PrimitivusWidget, quick_chat.QuickChat): False is generally used when printing history, when we don't want every message to be notified. """ + if message.attachments: + # FIXME: Q&D way to see attachments in Primitivus + # it should be done in a more user friendly way + for lang, body in message.message.items(): + for attachment in message.attachments: + if 'url' in attachment: + body+=f"\n{attachment['url']}" + elif 'path' in attachment: + path = Path(attachment['path']) + body+=f"\n{path.as_uri()}" + else: + log.warning(f'No "url" nor "path" in attachment: {attachment}') + message.message[lang] = body + if self.filters: if not all([f(message) for f in self.filters]): return