Add the network number in ZNC relay notifications

This commit is contained in:
Mark Veidemanis 2019-08-06 12:49:29 +01:00
parent c0b45c1db6
commit 56840e0060
2 changed files with 19 additions and 19 deletions

View File

@ -141,21 +141,21 @@ class IRCBot(IRCClient):
#event = None #event = None
#if self.nickname.lower() in msg.lower(): #if self.nickname.lower() in msg.lower():
# event = "highlight" # event = "highlight"
monitor.event(self.net, {"type": "msg", "nick": nick, "ident": ident, "host": host, "target": channel, "message": msg}) monitor.event(self.net, self.name, {"type": "msg", "nick": nick, "ident": ident, "host": host, "target": channel, "message": msg})
def noticed(self, user, channel, msg): def noticed(self, user, channel, msg):
nick, ident, host = self.parsen(user) nick, ident, host = self.parsen(user)
#userinfo.editUser(self.net, channel, nick, user) #userinfo.editUser(self.net, channel, nick, user)
count.event(self.net, "notice") count.event(self.net, "notice")
monitor.event(self.net, {"type": "notice", "nick": nick, "ident": ident, "host": host, "target": channel, "message": msg}) monitor.event(self.net, self.name, {"type": "notice", "nick": nick, "ident": ident, "host": host, "target": channel, "message": msg})
def action(self, user, channel, msg): def action(self, user, channel, msg):
nick, ident, host = self.parsen(user) nick, ident, host = self.parsen(user)
#userinfo.editUser(self.net, channel, nick, user) #userinfo.editUser(self.net, channel, nick, user)
count.event(self.net, "action") count.event(self.net, "action")
monitor.event(self.net, {"type": "action", "nick": nick, "ident": ident, "host": host, "target": channel, "message": msg}) monitor.event(self.net, self.name, {"type": "action", "nick": nick, "ident": ident, "host": host, "target": channel, "message": msg})
def get(self, var): def get(self, var):
try: try:
@ -208,7 +208,7 @@ class IRCBot(IRCClient):
n = self._who[channel][1] n = self._who[channel][1]
n.append([nick, user, host, server, status, realname]) n.append([nick, user, host, server, status, realname])
count.event(self.net, "whoreply") count.event(self.net, "whoreply")
monitor.event(self.net, {"type": "who", "nick": nick, "ident": user, "host": host, "realname": realname, "target": channel, "server": server, "status": status}) monitor.event(self.net, self.name, {"type": "who", "nick": nick, "ident": user, "host": host, "realname": realname, "target": 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]
@ -372,8 +372,8 @@ class IRCBot(IRCClient):
def left(self, user, channel, message): def left(self, user, channel, message):
nick, ident, host = self.parsen(user) nick, ident, host = self.parsen(user)
count.event(self.net, "selfpart") count.event(self.net, "selfpart")
monitor.event(self.net, {"type": "part", "target": channel, "message": message}) monitor.event(self.net, self.name, {"type": "part", "target": channel, "message": message})
monitor.event(self.net, {"type": "part", "self": True, "target": channel, "message": message}) monitor.event(self.net, self.name, {"type": "part", "self": True, "target": channel, "message": message})
self.botLeft(channel) self.botLeft(channel)
def kickedFrom(self, channel, kicker, message): def kickedFrom(self, channel, kicker, message):
@ -381,36 +381,36 @@ class IRCBot(IRCClient):
if channel in self.channels: if channel in self.channels:
self.channels.remove(channel) self.channels.remove(channel)
count.event(self.net, "selfkick") count.event(self.net, "selfkick")
monitor.event(self.net, {"type": "kick", "nick": nick, "ident": ident, "host": host, "target": channel, "message": message}) monitor.event(self.net, self.name, {"type": "kick", "nick": nick, "ident": ident, "host": host, "target": channel, "message": message})
monitor.event(self.net, {"type": "kick", "self": True, "nick": nick, "ident": ident, "host": host, "target": channel, "message": message}) monitor.event(self.net, self.name, {"type": "kick", "self": True, "nick": nick, "ident": ident, "host": host, "target": channel, "message": message})
self.botLeft(channel) self.botLeft(channel)
def userJoined(self, user, channel): def userJoined(self, user, channel):
nick, ident, host = self.parsen(user) nick, ident, host = self.parsen(user)
userinfo.addUser(self.net, channel, nick, user) userinfo.addUser(self.net, channel, nick, user)
count.event(self.net, "join") count.event(self.net, "join")
monitor.event(self.net, {"type": "join", "nick": nick, "ident": ident, "host": host, "target": channel}) monitor.event(self.net, self.name, {"type": "join", "nick": nick, "ident": ident, "host": host, "target": channel})
def userLeft(self, user, channel, message): def userLeft(self, user, channel, message):
nick, ident, host = self.parsen(user) nick, ident, host = self.parsen(user)
userinfo.delUser(self.net, channel, nick, user) userinfo.delUser(self.net, channel, nick, user)
count.event(self.net, "part") count.event(self.net, "part")
monitor.event(self.net, {"type": "part", "nick": nick, "ident": ident, "host": host, "target": channel, "message": message}) monitor.event(self.net, self.name, {"type": "part", "nick": nick, "ident": ident, "host": host, "target": channel, "message": message})
def userQuit(self, user, quitMessage): def userQuit(self, user, quitMessage):
nick, ident, host = self.parsen(user) nick, ident, host = self.parsen(user)
userinfo.delUserByNetwork(self.net, nick, user) userinfo.delUserByNetwork(self.net, nick, user)
count.event(self.net, "quit") count.event(self.net, "quit")
monitor.event(self.net, {"type": "quit", "nick": nick, "ident": ident, "host": host, "message": quitMessage}) monitor.event(self.net, self.name, {"type": "quit", "nick": nick, "ident": ident, "host": host, "message": quitMessage})
def botQuit(self, user, quitMessage): def botQuit(self, user, quitMessage):
nick, ident, host = self.parsen(user) nick, ident, host = self.parsen(user)
userinfo.delUserByNetwork(self.net, nick, user) userinfo.delUserByNetwork(self.net, nick, user)
count.event(self.net, "selfquit") count.event(self.net, "selfquit")
monitor.event(self.net, {"type": "quit", "nick": nick, "ident": ident, "host": host, "message": quitMessage}) monitor.event(self.net, self.name, {"type": "quit", "nick": nick, "ident": ident, "host": host, "message": quitMessage})
monitor.event(self.net, {"type": "quit", "self": True, "nick": nick, "ident": ident, "host": host, "message": quitMessage}) monitor.event(self.net, self.name, {"type": "quit", "self": True, "nick": nick, "ident": ident, "host": host, "message": quitMessage})
def userKicked(self, kickee, channel, kicker, message): def userKicked(self, kickee, channel, kicker, message):
nick, ident, host = self.parsen(kicker) nick, ident, host = self.parsen(kicker)
@ -418,20 +418,20 @@ class IRCBot(IRCClient):
userinfo.delUserByNick(self.net, channel, kickee) userinfo.delUserByNick(self.net, channel, kickee)
count.event(self.net, "kick") count.event(self.net, "kick")
monitor.event(self.net, {"type": "kick", "nick": nick, "ident": ident, "host": host, "target": channel, "message": message, "user": kickee}) monitor.event(self.net, self.name, {"type": "kick", "nick": nick, "ident": ident, "host": host, "target": channel, "message": message, "user": kickee})
def userRenamed(self, oldname, newname): def userRenamed(self, oldname, newname):
nick, ident, host = self.parsen(oldname) nick, ident, host = self.parsen(oldname)
userinfo.renameUser(self.net, nick, oldname, newname, newname+"!"+ident+"@"+host) userinfo.renameUser(self.net, nick, oldname, newname, newname+"!"+ident+"@"+host)
count.event(self.net, "nick") count.event(self.net, "nick")
monitor.event(self.net, {"type": "nick", "nick": nick, "ident": ident, "host": host, "user": newname}) monitor.event(self.net, self.name, {"type": "nick", "nick": nick, "ident": ident, "host": host, "user": newname})
def topicUpdated(self, user, channel, newTopic): def topicUpdated(self, user, channel, newTopic):
nick, ident, host = self.parsen(user) nick, ident, host = self.parsen(user)
userinfo.editUser(self.net, channel, nick, user) userinfo.editUser(self.net, channel, nick, user)
count.event(self.net, "topic") count.event(self.net, "topic")
monitor.event(self.net, {"type": "topic", "nick": nick, "ident": ident, "host": host, "target": channel, "message": newTopic}) monitor.event(self.net, self.name, {"type": "topic", "nick": nick, "ident": ident, "host": host, "target": channel, "message": newTopic})
def modeChanged(self, user, channel, toset, modes, args): def modeChanged(self, user, channel, toset, modes, args):
nick, ident, host = self.parsen(user) nick, ident, host = self.parsen(user)
@ -440,7 +440,7 @@ class IRCBot(IRCClient):
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):
monitor.event(self.net, {"type": "mode", "nick": nick, "ident": ident, "host": host, "target": channel, "modes": m, "modeargs": a}) monitor.event(self.net, self.name, {"type": "mode", "nick": nick, "ident": ident, "host": host, "target": channel, "modes": m, "modeargs": a})
class IRCBotFactory(ReconnectingClientFactory): class IRCBotFactory(ReconnectingClientFactory):
def __init__(self, name, relay=None, relayCommands=None, user=None, stage2=None): def __init__(self, name, relay=None, relayCommands=None, user=None, stage2=None):

View File

@ -50,7 +50,7 @@ def magicFunction(A, B):
else: else:
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(name, cast, event=None): def event(name, numberedName, cast, event=None):
if "target" in cast.keys(): if "target" in cast.keys():
target = cast["target"] target = cast["target"]
else: else:
@ -58,7 +58,7 @@ def event(name, cast, event=None):
if set(["nick", "ident", "host", "message"]).issubset(set(cast)): if set(["nick", "ident", "host", "message"]).issubset(set(cast)):
if main.config["Compat"]["ZNC"] and "message" in cast.keys(): if main.config["Compat"]["ZNC"] and "message" in cast.keys():
if cast["nick"][0] == main.config["Tweaks"]["ZNC"]["Prefix"] and cast["ident"] == "znc" and cast["host"] == "znc.in": if cast["nick"][0] == main.config["Tweaks"]["ZNC"]["Prefix"] and cast["ident"] == "znc" and cast["host"] == "znc.in":
sendRelayNotification(name, {"type": "znc", "message": cast["message"]}) sendRelayNotification(numberedName, {"type": "znc", "message": cast["message"]})
return return
sendRelayNotification(name, cast) sendRelayNotification(name, cast)