summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-cli/src/meshbay_cli/commands/chat.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-cli/src/meshbay_cli/commands/chat.py')
-rw-r--r--packages/meshbay-cli/src/meshbay_cli/commands/chat.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/packages/meshbay-cli/src/meshbay_cli/commands/chat.py b/packages/meshbay-cli/src/meshbay_cli/commands/chat.py
index d650af3..e410a6a 100644
--- a/packages/meshbay-cli/src/meshbay_cli/commands/chat.py
+++ b/packages/meshbay-cli/src/meshbay_cli/commands/chat.py
@@ -28,7 +28,7 @@ from ..client.groups import my_groups, open_group
from ..client.paths import group_arg, handle, resolve_group
from ..client.roster import RosterCheck
from ..errors import NODE, USAGE, CliError
-from ..output import date, err, safe, sentence
+from ..output import date, err, human_size, safe, sentence
from .context import Context
HELP = ("chat: alone, interactively; with a group, its last 10 messages (-N for N), "
@@ -147,6 +147,10 @@ def print_message(m, *, flush: bool = False) -> None:
print(f"{head}[this message cannot be read: {m.unreadable}]", flush=flush)
return
lines = safe_lines(m.text)
+ if m.attachment:
+ file_line = (f"[file: {safe(m.attachment['filename'])}, "
+ f"{human_size(m.attachment['size'])}]")
+ lines = [file_line] if lines == [""] else [file_line, *lines]
print(head + lines[0])
for line in lines[1:]:
print(" " * len(head) + line)
@@ -158,7 +162,8 @@ def print_message(m, *, flush: bool = False) -> None:
def as_json(m) -> dict:
return {"id": m.id, "timestamp": m.timestamp, "sender": m.sender, "text": m.text,
- "trust": m.trust, **({"unreadable": m.unreadable} if m.unreadable else {})}
+ "trust": m.trust, **({"unreadable": m.unreadable} if m.unreadable else {}),
+ **({"attachment": m.attachment} if m.attachment else {})}
class Follower: