From 56840e006039ee0915bfb714e40d91fbdcfb435d Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Tue, 6 Aug 2019 12:49:29 +0100 Subject: [PATCH] Add the network number in ZNC relay notifications --- core/bot.py | 34 +++++++++++++++++----------------- modules/monitor.py | 4 ++-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/core/bot.py b/core/bot.py index a783dca..bb91bc7 100644 --- a/core/bot.py +++ b/core/bot.py @@ -141,21 +141,21 @@ class IRCBot(IRCClient): #event = None #if self.nickname.lower() in msg.lower(): # 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): nick, ident, host = self.parsen(user) #userinfo.editUser(self.net, channel, nick, user) 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): nick, ident, host = self.parsen(user) #userinfo.editUser(self.net, channel, nick, user) 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): try: @@ -208,7 +208,7 @@ class IRCBot(IRCClient): n = self._who[channel][1] n.append([nick, user, host, server, status, realname]) 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): channel = params[1] @@ -372,8 +372,8 @@ class IRCBot(IRCClient): def left(self, user, channel, message): nick, ident, host = self.parsen(user) count.event(self.net, "selfpart") - monitor.event(self.net, {"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", "target": channel, "message": message}) + monitor.event(self.net, self.name, {"type": "part", "self": True, "target": channel, "message": message}) self.botLeft(channel) def kickedFrom(self, channel, kicker, message): @@ -381,36 +381,36 @@ class IRCBot(IRCClient): if channel in self.channels: self.channels.remove(channel) 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, {"type": "kick", "self": True, "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, self.name, {"type": "kick", "self": True, "nick": nick, "ident": ident, "host": host, "target": channel, "message": message}) self.botLeft(channel) def userJoined(self, user, channel): nick, ident, host = self.parsen(user) userinfo.addUser(self.net, channel, nick, user) 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): nick, ident, host = self.parsen(user) userinfo.delUser(self.net, channel, nick, user) 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): nick, ident, host = self.parsen(user) userinfo.delUserByNetwork(self.net, nick, user) 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): nick, ident, host = self.parsen(user) userinfo.delUserByNetwork(self.net, nick, user) count.event(self.net, "selfquit") - monitor.event(self.net, {"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", "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): nick, ident, host = self.parsen(kicker) @@ -418,20 +418,20 @@ class IRCBot(IRCClient): userinfo.delUserByNick(self.net, channel, kickee) 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): nick, ident, host = self.parsen(oldname) userinfo.renameUser(self.net, nick, oldname, newname, newname+"!"+ident+"@"+host) 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): nick, ident, host = self.parsen(user) userinfo.editUser(self.net, channel, nick, user) 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): nick, ident, host = self.parsen(user) @@ -440,7 +440,7 @@ class IRCBot(IRCClient): argList = list(args) modeList = [i for i in modes] 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): def __init__(self, name, relay=None, relayCommands=None, user=None, stage2=None): diff --git a/modules/monitor.py b/modules/monitor.py index 9ed1ca2..45f5118 100644 --- a/modules/monitor.py +++ b/modules/monitor.py @@ -50,7 +50,7 @@ def magicFunction(A, B): else: 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(): target = cast["target"] else: @@ -58,7 +58,7 @@ def event(name, cast, event=None): if set(["nick", "ident", "host", "message"]).issubset(set(cast)): 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": - sendRelayNotification(name, {"type": "znc", "message": cast["message"]}) + sendRelayNotification(numberedName, {"type": "znc", "message": cast["message"]}) return sendRelayNotification(name, cast)