Browse Source

rename !neighbours to !mesh and pimp its output

Helge Jung 9 years ago
parent
commit
61e3b07e44
1 changed files with 9 additions and 3 deletions
  1. 9 3
      modules/ffpb.py

+ 9 - 3
modules/ffpb.py

@@ -771,8 +771,8 @@ def ffpb_providers(bot, trigger):
 	providers.sort(key=lambda x: x['count'], reverse=True)
 	bot.say('Unsere Top 5 Provider: ' + ', '.join(['{0} ({1:.0f}%)'.format(x['name'], x['percentage']) for x in providers[:5]]))
 
-@willie.module.commands('neighbours')
-def ffpb_neighbours(bot, trigger):
+@willie.module.commands('mesh')
+def ffpb_nodemesh(bot, trigger):
 	target_name = trigger.group(2)
 	node = ffpb_findnode_from_botparam(bot, target_name, ensure_recent_alfreddata=False)
 	if node is None: return None
@@ -787,8 +787,14 @@ def ffpb_neighbours(bot, trigger):
 	for n in req:
 		ident,name = n.strip().split('=')
 		neighbours.add(name)
+	neighbours = [ x for x in neighbours ]
 
-	bot.say('; '.join(neighbours))
+	if len(neighbours) == 0:
+		bot.say(u'{0} hat keinen Mesh-Partner *schnüff*'.format(node['hostname']))
+	elif len(neighbours) == 1:
+		bot.say(u'{0} mesht mit \'{1}\''.format(node['hostname'], neighbours[0]))
+	else:
+		bot.say('{0} mesht mit \'{1}\' und \'{2}\''.format(node['hostname'], '\', \''.join(neighbours[:-1]), neighbours[-1]))
 
 @willie.module.commands('exec-on-peer')
 def ffpb_remoteexec(bot, trigger):