Browse Source

improve error handling in !mesh

A missing MAC was not handled correctly on top of it not being resolved
correctly (all in the case of a missing node_id).
Helge Jung 9 years ago
parent
commit
f0e4f91a99
1 changed files with 5 additions and 1 deletions
  1. 5 1
      modules/ffpb.py

+ 5 - 1
modules/ffpb.py

@@ -777,7 +777,11 @@ def ffpb_nodemesh(bot, trigger):
 	node = ffpb_findnode_from_botparam(bot, target_name, ensure_recent_alfreddata=False)
 	if node is None: return None
 
-	nodeid = node['node_id'] if 'node_id' in node else node['mac'].replace(':','')
+	nodeid = node['node_id'] if 'node_id' in node else None
+	if nodeid is None: nodeid = node['network']['mac'].replace(':','') if 'network' in node and 'mac' in node['network'] else None
+	if nodeid is None:
+		bot.say('Mist, ich habe gerade den Zettel verlegt auf dem die Node-ID von \'{0}\' steht, bitte frag später noch einmal.'.format(node['hostname'] if 'hostname' in node else target_name))
+		return
 	cave_result = json.load(urllib2.urlopen('http://[fdca:ffee:ff12:a255::253]:8888/node/{0}/neighbours'.format(nodeid)))
 
 	d = '&'.join([ str(n) for n in cave_result ])