Implement searching through the wholist

This commit is contained in:
Mark Veidemanis 2017-12-25 19:02:17 +00:00
parent 7e1e0ee0d2
commit 5b6bf59d7a
2 changed files with 35 additions and 0 deletions

View File

@ -6,6 +6,7 @@
"mod": "mod <name> [<key>] [<value>]",
"get": "get <name> <variable>",
"key": "key <master|show|add|del|except|unexcept|showexcept|monitor> [<name>] [<target>] [<key>] [<on|off>]",
"who": "who <nick>",
"join": "join <name> <channel> [<key>]",
"enable": "enable <name",
"disable": "disable <name>",

View File

@ -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: