|
@@ -6,11 +6,18 @@ import willie
|
|
|
from ffpb import \
|
|
|
ffpb_findnode_from_botparam, \
|
|
|
mac2ipv6, playitsafe, pretty_date
|
|
|
+from batcave import BatcaveClient
|
|
|
|
|
|
|
|
|
+__batcave = None
|
|
|
+
|
|
|
def setup(bot):
|
|
|
"""Called by willie upon loading this plugin."""
|
|
|
|
|
|
+ global __batcave, highscores
|
|
|
+
|
|
|
+ __batcave = BatcaveClient(bot.config.ffpb.batcave_url)
|
|
|
+
|
|
|
pass
|
|
|
|
|
|
|
|
@@ -20,6 +27,33 @@ def shutdown(bot):
|
|
|
pass
|
|
|
|
|
|
|
|
|
+@willie.module.commands('identify')
|
|
|
+def ffpb_identify(bot, trigger):
|
|
|
+ """Identify node."""
|
|
|
+
|
|
|
+ # query must be as OP in the channel
|
|
|
+ if not playitsafe(bot, trigger, via_channel=True, need_op=True):
|
|
|
+ # the check function already gives a bot reply, just exit here
|
|
|
+ return
|
|
|
+
|
|
|
+ ident = trigger.group(2)
|
|
|
+ result = __batcave.identify(ident)
|
|
|
+ if result is None:
|
|
|
+ bot.say('Mist, ich erreiche den Detektiv nicht.')
|
|
|
+ return
|
|
|
+
|
|
|
+ if not ident in result:
|
|
|
+ bot.say('Mein Detektiv hat getrunken und erzählt Blödsinn.')
|
|
|
+ return
|
|
|
+
|
|
|
+ if len(result[ident]) == 0:
|
|
|
+ bot.say('Trotz intensivster Recherche habe ich zu "%s" nix gefunden :/' % ident)
|
|
|
+ elif len(result[ident]) == 1:
|
|
|
+ bot.say('Glasklar, "%s" wurde identifiziert: %s' % (ident, result[ident][0]))
|
|
|
+ else:
|
|
|
+ bot.say('Hm, zu "%s" gibt es mehrere Möglichkeiten: %s' % (ident, str.join(', ', result[ident])))
|
|
|
+
|
|
|
+
|
|
|
@willie.module.commands('raw-data')
|
|
|
def ffpb_peerdata(bot, trigger):
|
|
|
"""Show ALFRED data of the given node."""
|