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

This commit is contained in:
Mark Veidemanis 2019-10-05 00:51:00 +01:00
parent ddadeb617c
commit 78e4d6bd66
3 changed files with 25 additions and 25 deletions

View File

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

View File

@ -149,10 +149,10 @@ class IRCBot(IRCClient):
del cast["nick"]
del cast["ident"]
del cast["host"]
del cast["target"]
del cast["channel"]
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 cast["target"].lower() == self.nickname.lower(): # as they are target == nickname
if "channel" in cast.keys() and not cast["type"] == "mode": # don't handle modes here
if cast["channel"].lower() == self.nickname.lower(): # as they are channel == nickname
#castDup = deepcopy(cast) # however modes are not queries!
cast["mtype"] = cast["type"]
cast["type"] = "query"
@ -173,7 +173,7 @@ class IRCBot(IRCClient):
castDup["mtype"] = cast["type"]
castDup["type"] = "self"
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
if "msg" in cast.keys() and not cast["type"] == "query": # Don't highlight queries
if not cast["msg"] == None:
@ -190,13 +190,13 @@ class IRCBot(IRCClient):
monitor.event(self.name, cast)
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):
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):
self.event(type="action", muser=user, target=channel, msg=msg)
self.event(type="action", muser=user, channel=channel, msg=msg)
def get(self, var):
try:
@ -251,7 +251,7 @@ class IRCBot(IRCClient):
return
n = self._tempWho[channel][1]
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):
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 --
# other bots have different nicknames so
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)
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):
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):
self.chanlessEvent({"type": "quit", "muser": user, "message": quitMessage})
@ -422,7 +422,7 @@ class IRCBot(IRCClient):
def userKicked(self, kickee, channel, kicker, message):
if kickee.lower() == self.nickname.lower():
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):
cast["nick"], cast["ident"], cast["host"] = self.parsen(cast["muser"])
@ -437,20 +437,20 @@ class IRCBot(IRCClient):
# ones we have common with them
realChans = set(chans).intersection(set(self.channels))
for i in realChans:
cast["target"] = i
cast["channel"] = i
self.event(**cast)
def userRenamed(self, oldname, newname):
self.chanlessEvent({"type": "nick", "muser": oldname, "user": newname})
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):
argList = list(args)
modeList = [i for i in modes]
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):
def __init__(self, net, num=None, relayCommands=None, user=None, stage2=None):

View File

@ -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)
def event(numName, c): # yes I'm using a short variable because otherwise it goes off the screen
if not "target" in c.keys():
c["target"] = None
if not "channel" in c.keys():
c["channel"] = None
if dedup(numName, c):
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"])
elif c["type"] == "kick":
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":
userinfo.delUserByNetwork(c["name"], c["nick"], c["muser"])
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":
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 c["mtype"] == "nick":
@ -85,7 +85,7 @@ def event(numName, c): # yes I'm using a short variable because otherwise it goe
sendRelayNotification(c)
# only monitors below
monitorGroups = testNetTarget(c["name"], c["target"])
monitorGroups = testNetTarget(c["name"], c["channel"])
if monitorGroups == False:
return
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():
for i in main.monitor[monitorGroup]["send"].keys():
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
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():
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]:
main.IRCPool[i].msg(x, "monitor [%s] (%s) %s" % (monitorGroup, c["name"], c))