|
@@ -41,7 +41,9 @@ def ffpb_peerdata(bot, trigger):
|
|
|
if key in ['hostname']:
|
|
|
continue
|
|
|
|
|
|
- bot.say("{0}.{1} = {2}".format(node['hostname'], key, node[key]))
|
|
|
+ bot.say("{0}.{1} = {2}".format(
|
|
|
+ node.get('hostname', '?-' + target_name),
|
|
|
+ key, node[key]))
|
|
|
|
|
|
|
|
|
@willie.module.commands('info')
|
|
@@ -112,30 +114,37 @@ def ffpb_lastseen(bot, trigger):
|
|
|
if node is None:
|
|
|
return
|
|
|
|
|
|
+ node_name = node.get('hostname')
|
|
|
+
|
|
|
last_seen = node.get('__UPDATED__')
|
|
|
- a_value = int(last_seen['alfred']) if (not last_seen is None) and 'alfred' in last_seen else None
|
|
|
- a_delta = time.time() - a_value if not a_value is None else None
|
|
|
- b_value = int(last_seen['batadv']) if (not last_seen is None) and 'batadv' in last_seen else None
|
|
|
- b_delta = time.time() - b_value if not b_value is None else None
|
|
|
+ if last_seen is not None:
|
|
|
+ a_value = int(last_seen.get('alfred'))
|
|
|
+ b_value = int(last_seen.get('batadv'))
|
|
|
+ else:
|
|
|
+ a_value = b_value = None
|
|
|
+
|
|
|
+ a_delta = time.time() - a_value if a_value is not None else None
|
|
|
+ b_delta = time.time() - b_value if b_value is not None else None
|
|
|
|
|
|
if a_value is None and b_value is None:
|
|
|
- bot.say('{0} wurde offenbar noch gar nicht gesehen?'.format(node['hostname']))
|
|
|
+ bot.say('{0} wurde offenbar noch gar nicht gesehen?'.format(node_name))
|
|
|
return
|
|
|
|
|
|
if a_delta < 30 and b_delta < 30:
|
|
|
- bot.say('{0} wurde gerade eben gesehen.'.format(node['hostname']))
|
|
|
+ bot.say('{0} wurde gerade eben gesehen.'.format(node_name))
|
|
|
return
|
|
|
|
|
|
- if a_value is not None and b_value is not None and abs(a_value - b_value) < 60:
|
|
|
+ if a_value is not None and b_value is not None and \
|
|
|
+ abs(a_value - b_value) < 60:
|
|
|
bot.say('{0} wurde zuletzt gesehen: {1}'.format(
|
|
|
- node['hostname'],
|
|
|
+ node_name,
|
|
|
pretty_date((a_value + b_value) / 2)))
|
|
|
else:
|
|
|
bot.say('{0} wurde zuletzt gesehen: {1} (ALFRED,) bzw. {2} (BATMAN)'.format(
|
|
|
- node['hostname'],
|
|
|
- pretty_date(a_value) if not a_value is None else "nie",
|
|
|
- pretty_date(b_value) if not b_value is None else "nie"
|
|
|
- ))
|
|
|
+ node_name,
|
|
|
+ pretty_date(a_value) if not a_value is None else "nie",
|
|
|
+ pretty_date(b_value) if not b_value is None else "nie"
|
|
|
+ ))
|
|
|
|
|
|
|
|
|
@willie.module.commands('uptime')
|
|
@@ -194,4 +203,5 @@ def ffpb_peerlink(bot, trigger):
|
|
|
info_v6 = mac2ipv6(info_mac, 'fdca:ffee:ff12:132:')
|
|
|
|
|
|
# reply to user
|
|
|
- bot.say('[{1}] mac {0} -> http://[{2}]/'.format(info_mac, info_name, info_v6))
|
|
|
+ bot.say('[{1}] mac {0} -> http://[{2}]/'.format(
|
|
|
+ info_mac, info_name, info_v6))
|