From 0ff56e7423edfd1a64afc44b0836c5ccd39a01b6 Mon Sep 17 00:00:00 2001 From: fphemeral <fphemeral@i2pmail.org> Date: Sat, 13 Feb 2021 11:04:41 +0000 Subject: [PATCH] add show contacts detailed --- briar_repl/contacts.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/briar_repl/contacts.py b/briar_repl/contacts.py index b061666..c425799 100644 --- a/briar_repl/contacts.py +++ b/briar_repl/contacts.py @@ -1,3 +1,4 @@ +import datetime from pprint import pprint import colorful as col from .start_up import URLS @@ -40,7 +41,7 @@ async def init_contacts(): all_contacts_by_alias[alias_or_name] = contact -async def show_contacts(): +async def show_contacts(detailed=None): """ lists your contacts """ @@ -53,8 +54,18 @@ async def show_contacts(): for contact in contacts_by_last_act: online = col.bold_chartreuse("online") if contact.is_online else "" unread_count = contact.unread_msgs if contact.unread_msgs else '' - print(f"{contact.cid:4}: {contact.alias} {online} {col.bold_orange(unread_count)}") - return + last_act = datetime.datetime.fromtimestamp(contact.last_activity / 1000).strftime('%Y-%m-%d %H:%M') + if detailed: + print(f"{contact.cid:4} {last_act}: {contact.alias} {online} {col.bold_orange(unread_count)}") + else: + print(f" {contact.alias} {online} {col.bold_orange(unread_count)}") + + +async def show_contacts_detailed(): + """ + lists your contacts with details + """ + await show_contacts(detailed=True) async def show_contact_info(contact_str): -- GitLab