Browse Source

der Bot schaut gelegentlich in den Rückspiegel

Helge Jung 9 years ago
parent
commit
4f2dd39a39
1 changed files with 15 additions and 0 deletions
  1. 15 0
      modules/ffpb_hamburg.py

+ 15 - 0
modules/ffpb_hamburg.py

@@ -20,6 +20,21 @@ def shutdown(bot):
 def ffpb_hamburg_fetch(bot):
 	ffpb_fetch_stats(bot, 'http://hamburg.freifunk.net/nodes_ffhh/nodes.json', 'ffhh_stats')
 
+	if 'ffhh_rueckspiegel' in bot.memory and bot.memory['ffhh_rueckspiegel'] == True:
+		return
+
+	stats = bot.memory['ffpb_stats'] if 'ffpb_stats' in bot.memory else None
+	hamburg_data = bot.memory['ffhh_stats'] if 'ffhh_stats' in bot.memory else None
+	if not (stats is None or hamburg_data is None):
+		if hamburg_data['nodes_active'] < stats['nodes_active']:
+			print('HAMBURG überholt: {0}<{1}'.format(hamburg_data['nodes_active'], stats['nodes_active']))
+			bot.memory['ffhh_rueckspiegel'] = True
+
+			action_msg = u'schaut in den Rückspiegel und erblickt HAMBURG!'
+			action_target = bot.config.ffpb.msg_target
+			if not bot.config.ffpb.msg_target_public is None: action_target = bot.config.ffpb.msg_target_public
+			bot.msg(action_target, '\x01ACTION %s\x01' % action_msg)
+
 @willie.module.commands('hamburg')
 def ffpb_hamburg(bot, trigger):
 	hamburg_data = bot.memory['ffhh_stats'] if 'ffhh_stats' in bot.memory else None