Browse Source

status: cache value each 5s

Helge Jung 9 years ago
parent
commit
d0a1dd0ea1
1 changed files with 4 additions and 2 deletions
  1. 4 2
      modules/ffpb_netstatus.py

+ 4 - 2
modules/ffpb_netstatus.py

@@ -43,7 +43,7 @@ def shutdown(bot):
         highscores = None
 
 
-@willie.module.interval(15)
+@willie.module.interval(5)
 def ffpb_get_stats(bot):
     """Fetch current statistics, if the highscore changes signal this."""
 
@@ -52,6 +52,8 @@ def ffpb_get_stats(bot):
         bot.say('Yikes, offenbar ist das allwissende Auge gerade schlafen.')
         return
 
+    bot.memory['ffpb_stats'] = status
+
     (nodes_active, clients_count) = \
         (status['nodes_active'], status['clients_unique'])
 
@@ -90,7 +92,7 @@ def ffpb_get_stats(bot):
 def ffpb_status(bot, trigger):
     """State of the network: count of nodes + clients"""
 
-    stats = __batcave.get_status()
+    stats = bot.memory.get('ffpb_stats')
     if stats is None:
         bot.say('Uff, kein Plan wo der Zettel ist. Fragst du später nochmal?')
         return