# HG changeset patch # User Goffi # Date 1582750995 -3600 # Node ID 1c6dacbfcf271fa4cff87a76e0671c3bc5a7ecfd # Parent 142ecb7f6338a13be3fbc4a2a6949e3ed9dcf1bd primitivus (chat) Q&D way to see attachments diff -r 142ecb7f6338 -r 1c6dacbfcf27 sat_frontends/primitivus/chat.py --- a/sat_frontends/primitivus/chat.py Wed Feb 26 22:03:15 2020 +0100 +++ b/sat_frontends/primitivus/chat.py Wed Feb 26 22:03:15 2020 +0100 @@ -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 @@ 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