Просмотр исходного кода

ffpb.py: no channel messages if comand returned no output

Stefan Kloepping 10 лет назад
Родитель
Сommit
c6d3bae0a6
1 измененных файлов с 14 добавлено и 2 удалено
  1. 14 2
      modules/ffpb.py

+ 14 - 2
modules/ffpb.py

@@ -69,6 +69,14 @@ def shutdown(bot):
 		print("Closed messaging server.")
 		msgserver = None
 
+@willie.module.commands('tescht')
+def ffpb_tescht(bot, trigger):
+	bot.say ('ich sage mal hallo ' + trigger.nick)
+
+
+"""TODO: check if nickname that is triggering $command is allow for $node"""
+
+
 @willie.module.commands('status')
 def ffpb_status(bot, trigger):
 	"""Status des FFPB-Netzes: Anzahl (aktiver) Knoten + Clients"""
@@ -150,10 +158,14 @@ def ffpb_remoteexec(bot, trigger):
 	try:
 		result = subprocess.check_output(['ssh', '-6n', '-l', 'root', '-o', 'BatchMode=yes', '-o','StrictHostKeyChecking=no', target, target_cmd], stderr=subprocess.STDOUT, shell=False)
 		lines = str(result).splitlines()
+
+		if len(lines) == 0:
+			bot.say('exec-on-peer(' + target_name + '): No output')
+			return
+
 		bot.say('exec-on-peer(' + target_name + '): ' + str(len(lines)) + ' Zeilen (zeige max. 8):')
 		for line in lines[0:8]:
 			bot.say(line)
-		
+
 	except subprocess.CalledProcessError, e:
 		bot.say('Fehler '+str(e.returncode)+' bei exec-on-peer('+target_name+'): ' + e.output)
-