From 5b6bf59d7aeaf9766c491d1ba2a910cba243e013 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Mon, 25 Dec 2017 19:02:17 +0000 Subject: [PATCH] Implement searching through the wholist --- help.json | 1 + threshold | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/help.json b/help.json index d87f86f..7322907 100644 --- a/help.json +++ b/help.json @@ -6,6 +6,7 @@ "mod": "mod [] []", "get": "get ", "key": "key [] [] [] []", + "who": "who ", "join": "join []", "enable": "enable ", diff --git a/threshold b/threshold index c630333..cd5d205 100755 --- a/threshold +++ b/threshold @@ -194,6 +194,7 @@ class IRCBot(IRCClient): def signedOn(self): self.connected = True + log("signed on: %s" % self.name) if self.authtype == "ns": self.msg(self.authentity, "IDENTIFY %s" % self.nspass) for i in self.autojoin: @@ -315,6 +316,18 @@ class Helper(object): if nick in wholist[network].keys(): wholist[network][nick][1] = ident wholist[network][nick][2] = host + else: + wholist[network][nick] = [nick, ident, host, None, None, None] + + def getWho(self, nick): + result = {} + for i in wholist.keys(): + for x in wholist[i].keys(): + if nick.lower() == x.lower(): + if not i in result.keys(): + result[i] = [] + result[i].append(wholist[i][x]) + return result def saveConfig(self): global config @@ -616,6 +629,23 @@ class Helper(object): incUsage("get") return + elif cmd == "who": + global wholist + if length == 2: + result = self.getWho(spl[1]) + rtrn = "" + for i in result.keys(): + rtrn += "Matches from: %s" % i + rtrn += "\n" + for x in result[i]: + rtrn += (", ".join(x)) + rtrn += "\n" + info(rtrn) + return + else: + incUsage("who") + return + elif cmd == "key": if data.startswith("key add"): if not data in ["key add ", "key add"] and data[3] == " ": @@ -752,6 +782,10 @@ class Helper(object): incUsage("key") return + else: + incUsage("key") + return + elif cmd == "add": if length == 6: