|
@@ -180,6 +180,45 @@ def ffpb_updatealfred(bot):
|
|
|
print("Unknown ALFRED data method '", alfred_method, "', cannot load new data.", sep="")
|
|
|
alfred_data = None
|
|
|
|
|
|
+@willie.module.commands('info')
|
|
|
+def ffpb_peerinfo(bot, trigger):
|
|
|
+ target_name = trigger.group(2)
|
|
|
+ if (target_name is None or len(target_name) == 0):
|
|
|
+ bot.say(str(trigger.nick + ": Grün."))
|
|
|
+ return
|
|
|
+
|
|
|
+ if alfred_data is None:
|
|
|
+ bot.say("Informationen sind ausverkauft, kommen erst morgen wieder rein.")
|
|
|
+ return
|
|
|
+
|
|
|
+ node = ffpb_findnode(target_name)
|
|
|
+ if node is None:
|
|
|
+ bot.say("Kein Plan wer oder was mit '" + target_name + "' gemeint ist :(")
|
|
|
+ return
|
|
|
+
|
|
|
+ info_mac = node["network"]["mac"]
|
|
|
+ info_name = node["hostname"]
|
|
|
+
|
|
|
+ info_fw = ""
|
|
|
+ info_update = ""
|
|
|
+ if "software" in node:
|
|
|
+ if "firmware" in node["software"]:
|
|
|
+ fwinfo = str(node["software"]["firmware"]["release"]) if "release" in node["software"]["firmware"] else "unknown"
|
|
|
+ info_fw = " firmware " + fwinfo
|
|
|
+
|
|
|
+ if "autoupdater" in node["software"]:
|
|
|
+ autoupdater = node["software"]["autoupdater"]["branch"] if node["software"]["autoupdater"]["enabled"] else "off"
|
|
|
+ info_update = " (autoupdater="+autoupdater+")"
|
|
|
+
|
|
|
+ info_uptime = ""
|
|
|
+ if "statistics" in node and "uptime" in node["statistics"]:
|
|
|
+ u = int(float(node["statistics"]["uptime"]))
|
|
|
+ h, r = divmod(int(float(node["statistics"]["uptime"])), 3600)
|
|
|
+ m, s = divmod(r, 60)
|
|
|
+ info_uptime = ' up {0}h {1}m'.format(h,m) if h > 0 else ' up {0}m'.format(m)
|
|
|
+
|
|
|
+ bot.say('[{0}] {1}{2}{3}{4}'.format(info_mac, info_name, info_fw, info_update, info_uptime))
|
|
|
+
|
|
|
@willie.module.interval(60)
|
|
|
def ffpb_updatepeers(bot):
|
|
|
"""Aktualisiere die Knotenliste und melde das Diff"""
|