Make /status and /nick display your own if run with no arguments, and move listing of all peers to /peers

This commit is contained in:
Juhani Krekelä 2019-07-16 12:32:07 +03:00
parent 6abb09b0c9
commit 6c3820c42f
1 changed files with 25 additions and 9 deletions

View File

@ -230,17 +230,21 @@ def handle_user_command(backend, line):
queue_message(backend, mac, message)
elif command == '/status':
# Request status
if rest != '':
# Request status
mac = mac_from_name(rest)
if mac in peers:
print('%s === ~%s (%s) [%s]' % (timestamp(), peers[mac].nick, peers[mac].status.name, format_mac(mac)))
send_status_request(backend, mac)
else:
# List all the known peers
for mac, peer in peers.items():
print('%s === ~%s (%s) [%s]' % (timestamp(), peer.nick, peer.status.name, format_mac(mac)))
# Show own
print('--- %s' % own_status.name)
elif command == '/peers' and rest == '':
# List all the known peers
for mac, peer in peers.items():
print('--- ~%s (%s) [%s]' % (timestamp(), peer.nick, peer.status.name, format_mac(mac)))
elif command == '/available' and rest == '':
# Set status to available
@ -253,11 +257,23 @@ def handle_user_command(backend, line):
set_status_nick(backend, own_status, own_nick)
elif command == '/nick':
# Change nick
validate_nick(rest)
if rest != '':
# Change nick
if rest[0] == '~':
# Remove the ~ from the front if it is there
nick = rest[1:]
else:
nick = rest
own_nick = rest
set_status_nick(backend, own_status, own_nick)
validate_nick(nick)
own_nick = nick
set_status_nick(backend, own_status, own_nick)
else:
# Show own
print('--- ~%s' % own_nick)
elif command == '/target':
# Set default target of messages
@ -269,7 +285,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>]; /peers; /available; /unavailable; /nick [<nick>]; /target <target>; /quit')
else:
# Send message