Rename 'message' to 'msg' and 'target' to 'channel'

pull/1/head
Mark Veidemanis 5 years ago
parent ddadeb617c
commit 78e4d6bd66

@ -21,7 +21,7 @@
"relay": "relay <add|del|list> [<network>] [<num>]", "relay": "relay <add|del|list> [<network>] [<num>]",
"network": "network <add|del|list> [<name> <address> <port> <ssl|plain> <sasl|ns|none>]", "network": "network <add|del|list> [<name> <address> <port> <ssl|plain> <sasl|ns|none>]",
"alias": "alias [<add|del>] [<num>]", "alias": "alias [<add|del>] [<num>]",
"auto": "auto <network> <relay>", "auto": "auto [<network>] [<relay>]",
"cmd": "cmd <relay> <user> <entity> <text ...>", "cmd": "cmd <relay> <user> <entity> <text ...>",
"token": "token <add|del|list> [<key>] [<relay>]", "token": "token <add|del|list> [<key>] [<relay>]",
"all": "all <entity> <text ...>", "all": "all <entity> <text ...>",

@ -149,10 +149,10 @@ class IRCBot(IRCClient):
del cast["nick"] del cast["nick"]
del cast["ident"] del cast["ident"]
del cast["host"] del cast["host"]
del cast["target"] del cast["channel"]
if not cast["type"] in ["query", "self", "highlight", "znc", "who"]: if not cast["type"] in ["query", "self", "highlight", "znc", "who"]:
if "target" in cast.keys() and not cast["type"] == "mode": # don't handle modes here if "channel" in cast.keys() and not cast["type"] == "mode": # don't handle modes here
if cast["target"].lower() == self.nickname.lower(): # as they are target == nickname if cast["channel"].lower() == self.nickname.lower(): # as they are channel == nickname
#castDup = deepcopy(cast) # however modes are not queries! #castDup = deepcopy(cast) # however modes are not queries!
cast["mtype"] = cast["type"] cast["mtype"] = cast["type"]
cast["type"] = "query" cast["type"] = "query"
@ -173,7 +173,7 @@ class IRCBot(IRCClient):
castDup["mtype"] = cast["type"] castDup["mtype"] = cast["type"]
castDup["type"] = "self" castDup["type"] = "self"
castDup["name"] = self.name castDup["name"] = self.name
if not cast["target"].lower() == self.nickname.lower(): # modes has been set on us directly if not cast["channel"].lower() == self.nickname.lower(): # modes has been set on us directly
self.event(**castDup) # don't tell anyone else self.event(**castDup) # don't tell anyone else
if "msg" in cast.keys() and not cast["type"] == "query": # Don't highlight queries if "msg" in cast.keys() and not cast["type"] == "query": # Don't highlight queries
if not cast["msg"] == None: if not cast["msg"] == None:
@ -190,13 +190,13 @@ class IRCBot(IRCClient):
monitor.event(self.name, cast) monitor.event(self.name, cast)
def privmsg(self, user, channel, msg): def privmsg(self, user, channel, msg):
self.event(type="msg", muser=user, target=channel, msg=msg) self.event(type="msg", muser=user, channel=channel, msg=msg)
def noticed(self, user, channel, msg): def noticed(self, user, channel, msg):
self.event(type="notice", muser=user, target=channel, msg=msg) self.event(type="notice", muser=user, channel=channel, msg=msg)
def action(self, user, channel, msg): def action(self, user, channel, msg):
self.event(type="action", muser=user, target=channel, msg=msg) self.event(type="action", muser=user, channel=channel, msg=msg)
def get(self, var): def get(self, var):
try: try:
@ -251,7 +251,7 @@ class IRCBot(IRCClient):
return return
n = self._tempWho[channel][1] n = self._tempWho[channel][1]
n.append([nick, nick, host, server, status, realname]) n.append([nick, nick, host, server, status, realname])
self.event(type="who", nick=nick, ident=ident, host=host, realname=realname, target=channel, server=server, status=status) self.event(type="who", nick=nick, ident=ident, host=host, realname=realname, channel=channel, server=server, status=status)
def irc_RPL_ENDOFWHO(self, prefix, params): def irc_RPL_ENDOFWHO(self, prefix, params):
channel = params[1] channel = params[1]
@ -407,14 +407,14 @@ class IRCBot(IRCClient):
#log("Can no longer cover %s, removing records" % channel)# as it will only be matched once -- #log("Can no longer cover %s, removing records" % channel)# as it will only be matched once --
# other bots have different nicknames so # other bots have different nicknames so
def left(self, user, channel, message): # even if they saw it, they wouldn't react def left(self, user, channel, message): # even if they saw it, they wouldn't react
self.event(type="part", muser=user, target=channel, message=message) self.event(type="part", muser=user, channel=channel, message=message)
self.botLeft(channel) self.botLeft(channel)
def userJoined(self, user, channel): def userJoined(self, user, channel):
self.event(type="join", muser=user, target=channel) self.event(type="join", muser=user, channel=channel)
def userLeft(self, user, channel, message): def userLeft(self, user, channel, message):
self.event(type="part", muser=user, target=channel, message=message) self.event(type="part", muser=user, channel=channel, message=message)
def userQuit(self, user, quitMessage): def userQuit(self, user, quitMessage):
self.chanlessEvent({"type": "quit", "muser": user, "message": quitMessage}) self.chanlessEvent({"type": "quit", "muser": user, "message": quitMessage})
@ -422,7 +422,7 @@ class IRCBot(IRCClient):
def userKicked(self, kickee, channel, kicker, message): def userKicked(self, kickee, channel, kicker, message):
if kickee.lower() == self.nickname.lower(): if kickee.lower() == self.nickname.lower():
self.botLeft(channel) self.botLeft(channel)
self.event(type="kick", muser=kicker, target=channel, message=message, user=kickee) self.event(type="kick", muser=kicker, channel=channel, message=message, user=kickee)
def chanlessEvent(self, cast): def chanlessEvent(self, cast):
cast["nick"], cast["ident"], cast["host"] = self.parsen(cast["muser"]) cast["nick"], cast["ident"], cast["host"] = self.parsen(cast["muser"])
@ -437,20 +437,20 @@ class IRCBot(IRCClient):
# ones we have common with them # ones we have common with them
realChans = set(chans).intersection(set(self.channels)) realChans = set(chans).intersection(set(self.channels))
for i in realChans: for i in realChans:
cast["target"] = i cast["channel"] = i
self.event(**cast) self.event(**cast)
def userRenamed(self, oldname, newname): def userRenamed(self, oldname, newname):
self.chanlessEvent({"type": "nick", "muser": oldname, "user": newname}) self.chanlessEvent({"type": "nick", "muser": oldname, "user": newname})
def topicUpdated(self, user, channel, newTopic): def topicUpdated(self, user, channel, newTopic):
self.event(type="topic", muser=user, target=channel, message= newTopic) self.event(type="topic", muser=user, channel=channel, message= newTopic)
def modeChanged(self, user, channel, toset, modes, args): def modeChanged(self, user, channel, toset, modes, args):
argList = list(args) argList = list(args)
modeList = [i for i in modes] modeList = [i for i in modes]
for a, m in zip(argList, modeList): for a, m in zip(argList, modeList):
self.event(type="mode", muser=user, target=channel, modes=m, status=toset, modeargs=a) self.event(type="mode", muser=user, channel=channel, modes=m, status=toset, modeargs=a)
class IRCBotFactory(ReconnectingClientFactory): class IRCBotFactory(ReconnectingClientFactory):
def __init__(self, net, num=None, relayCommands=None, user=None, stage2=None): def __init__(self, net, num=None, relayCommands=None, user=None, stage2=None):

@ -54,8 +54,8 @@ def magicFunction(A, B):
return all(A[k] in B[k] for k in set(A) & set(B)) and set(B) <= set(A) return all(A[k] in B[k] for k in set(A) & set(B)) and set(B) <= set(A)
def event(numName, c): # yes I'm using a short variable because otherwise it goes off the screen def event(numName, c): # yes I'm using a short variable because otherwise it goes off the screen
if not "target" in c.keys(): if not "channel" in c.keys():
c["target"] = None c["channel"] = None
if dedup(numName, c): if dedup(numName, c):
return return
@ -68,13 +68,13 @@ def event(numName, c): # yes I'm using a short variable because otherwise it goe
userinfo.renameUser(c["name"], c["nick"], c["muser"], c["user"], c["user"]+"!"+c["ident"]+"@"+c["host"]) userinfo.renameUser(c["name"], c["nick"], c["muser"], c["user"], c["user"]+"!"+c["ident"]+"@"+c["host"])
elif c["type"] == "kick": elif c["type"] == "kick":
userinfo.editUser(c["name"], c["muser"]) userinfo.editUser(c["name"], c["muser"])
userinfo.delUserByNick(c["name"], c["target"], c["user"]) userinfo.delUserByNick(c["name"], c["channel"], c["user"])
elif c["type"] == "quit": elif c["type"] == "quit":
userinfo.delUserByNetwork(c["name"], c["nick"], c["muser"]) userinfo.delUserByNetwork(c["name"], c["nick"], c["muser"])
elif c["type"] == "join": elif c["type"] == "join":
userinfo.addUser(c["name"], c["target"], c["nick"], c["muser"]) userinfo.addUser(c["name"], c["channel"], c["nick"], c["muser"])
elif c["type"] == "part": elif c["type"] == "part":
userinfo.delUser(c["name"], c["target"], c["nick"], c["muser"]) userinfo.delUser(c["name"], c["channel"], c["nick"], c["muser"])
if "mtype" in c.keys(): if "mtype" in c.keys():
if c["mtype"] == "nick": if c["mtype"] == "nick":
@ -85,7 +85,7 @@ def event(numName, c): # yes I'm using a short variable because otherwise it goe
sendRelayNotification(c) sendRelayNotification(c)
# only monitors below # only monitors below
monitorGroups = testNetTarget(c["name"], c["target"]) monitorGroups = testNetTarget(c["name"], c["channel"])
if monitorGroups == False: if monitorGroups == False:
return return
for monitorGroup in monitorGroups: for monitorGroup in monitorGroups:
@ -95,11 +95,11 @@ def event(numName, c): # yes I'm using a short variable because otherwise it goe
if "send" in main.monitor[monitorGroup].keys(): if "send" in main.monitor[monitorGroup].keys():
for i in main.monitor[monitorGroup]["send"].keys(): for i in main.monitor[monitorGroup]["send"].keys():
if isinstance(main.monitor[monitorGroup]["send"][i], bool): if isinstance(main.monitor[monitorGroup]["send"][i], bool):
sendRelayNotification({"type": "err", "name": name, "target": target, "message": c, "reason": "errdeliv"}) sendRelayNotification({"type": "err", "name": name, "channel": channel, "message": c, "reason": "errdeliv"})
continue continue
if not i in main.pool.keys(): if not i in main.pool.keys():
sendRelayNotification({"type": "err", "name": name, "target": target, "message": c, "reason": "noname"}) sendRelayNotification({"type": "err", "name": name, "channel": channel, "message": c, "reason": "noname"})
if not i in main.IRCPool.keys(): if not i in main.IRCPool.keys():
sendRelayNotification({"type": "err", "name": name, "target": target, "message": c, "reason": "noinstance"}) sendRelayNotification({"type": "err", "name": name, "channel": channel, "message": c, "reason": "noinstance"})
for x in main.monitor[monitorGroup]["send"][i]: for x in main.monitor[monitorGroup]["send"][i]:
main.IRCPool[i].msg(x, "monitor [%s] (%s) %s" % (monitorGroup, c["name"], c)) main.IRCPool[i].msg(x, "monitor [%s] (%s) %s" % (monitorGroup, c["name"], c))

Loading…
Cancel
Save