List all known peers if /status called without a target

This commit is contained in:
Juhani Krekelä 2019-07-15 20:43:29 +03:00
parent a140fde1c1
commit 90c435cfd9
1 changed files with 11 additions and 5 deletions

View File

@ -178,11 +178,17 @@ def handle_user_command(backend, line):
elif command == '/status':
# Request status
mac = mac_from_name(rest)
if mac in peers:
print('=== ~%s (%s) [%s]' % (peers[mac].nick, peers[mac].status.name, format_mac(mac)))
if rest != '':
mac = mac_from_name(rest)
if mac in peers:
print('=== ~%s (%s) [%s]' % (peers[mac].nick, peers[mac].status.name, format_mac(mac)))
else:
send_status_request(backend, mac)
else:
send_status_request(backend, mac)
# List all the known peers
for mac, peer in peers.items():
print('=== ~%s (%s) [%s]' % (peer.nick, peer.status.name, format_mac(mac)))
elif command == '/available' and rest == '':
# Set status to available
@ -210,7 +216,7 @@ def handle_user_command(backend, line):
else:
# Display usage
print('--- / <message>; /msg <target> <message>; /status <target>; /available; /unavailable; /nick <nick>; /target <target>; /quit')
print('--- / <message>; /msg <target> <message>; /status [<target>]; /available; /unavailable; /nick <nick>; /target <target>; /quit')
except NoMatchesError as err:
print('--- name %s matches no peers' % err.args[0])