diff --git a/briar_repl/contacts.py b/briar_repl/contacts.py index b06166640d6c7d7915c22033f525010a3f58220c..c42579941c5a8652e781bc6fa5e348a70006394d 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):