Browse Source

ffpb_ping() got new argument 'reply_directly=True'

Set this to False instead of setting bot to None.
Helge Jung 9 years ago
parent
commit
9a2edc53be
2 changed files with 5 additions and 5 deletions
  1. 4 4
      modules/ffpb.py
  2. 1 1
      modules/ffpb_monitoring.py

+ 4 - 4
modules/ffpb.py

@@ -916,7 +916,7 @@ def ffpb_rolloutstatus(bot, trigger):
 		bot.say('plus {0} Knoten deren Status gerade nicht abfragbar war'.format(skipped))
 
 @willie.module.commands('ping')
-def ffpb_ping(bot, trigger=None, target_name=None):
+def ffpb_ping(bot, trigger=None, target_name=None, reply_directly=True):
 	"""Ping the given node"""
 
 	# identify node or bail out
@@ -933,15 +933,15 @@ def ffpb_ping(bot, trigger=None, target_name=None):
 	result = os.system('ping6 -c 2 -W 1 ' + target + ' >/dev/null')
 	if result == 0:
 		print("ping to '{0}' succeeded".format(target_name))
-		if not bot is None: bot.say('Knoten "' + target_alias + '" antwortet \o/')
+		if reply_directly: bot.say('Knoten "' + target_alias + '" antwortet \o/')
 		return True
 	elif result == 1 or result == 256:
 		print("ping to '{0}' failed".format(target_name))
-		if not bot is None: bot.say('Keine Antwort von "' + target_alias + '" :-(')
+		if reply_directly: bot.say('Keine Antwort von "' + target_alias + '" :-(')
 		return False
 	else:
 		print("ping to '{0}' broken: result='{1}'".format(target_name, result))
-		if not bot is None: bot.say('Uh oh, irgendwas ist kaputt. Chef, ping result = ' + str(result) + ' - darf ich das essen?')
+		if reply_directly: bot.say('Uh oh, irgendwas ist kaputt. Chef, ping result = ' + str(result) + ' - darf ich das essen?')
 		return None
 
 @willie.module.commands('providers')

+ 1 - 1
modules/ffpb_monitoring.py

@@ -40,7 +40,7 @@ def ffpb_monitor_ping(bot):
 		last_check = mon['last_check']
 		last_success = mon['last_success']
 
-		current_status = ffpb_ping(bot=None, target_name=node)
+		current_status = ffpb_ping(bot=bot, target_name=node, reply_directly=False)
 		if current_status is None: current_status = False
 		mon['status'] = current_status
 		mon['last_check'] = time.time()