From 7d9a45ee91645e7f000330aa6d214f6b8d578fea Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Wed, 28 Oct 2020 22:26:41 +0000 Subject: [PATCH] Add the time field to some notifications --- core/bot.py | 20 ++++++++++++++------ modules/monitor.py | 4 ++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/core/bot.py b/core/bot.py index 53dac25..04299a2 100644 --- a/core/bot.py +++ b/core/bot.py @@ -135,7 +135,7 @@ class IRCBot(IRCClient): relay = main.network[self.net].relays[num] self.nickname = alias["nick"] self.realname = alias["realname"] - self.username = alias["nick"]+"/"+relay["net"] + self.username = alias["nick"].lower()+"/"+relay["net"] self.password = main.config["Relay"]["Password"] self.userinfo = None # self.fingerReply = None # @@ -335,8 +335,8 @@ class IRCBot(IRCClient): self.setNick(self._attemptedNick) def irc_ERR_PASSWDMISMATCH(self, prefix, params): - log("%s - %i: password mismatch" % (self.net, self.num)) - sendAll("%s - %i: password mismatch" % (self.net, self.num)) + log("%s - %i: password mismatch as %s" % (self.net, self.num, self.username)) + sendAll("%s - %i: password mismatch as %s" % (self.net, self.num, self.username)) def _who(self, channel): d = Deferred() @@ -618,7 +618,12 @@ class IRCBot(IRCClient): def signedOn(self): log("signed on: %s - %i" % (self.net, self.num)) - sendRelayNotification({"type": "conn", "net": self.net, "num": self.num, "status": "signedon"}) + ctime = str(datetime.now().isoformat()) + sendRelayNotification({"type": "conn", "net": self.net, "num": self.num, "status": "signedon", "time": ctime}) + if not self.authenticated: + inst = regproc.selectInst(self.net) + if inst["ping"] and inst["check"]: + self.msg(inst["entity"], inst["pingmsg"]) def joined(self, channel): if not channel in self.channels: @@ -661,6 +666,7 @@ class IRCBot(IRCClient): self.event(type="kick", muser=kicker, channel=channel, msg=message, user=kickee) def chanlessEvent(self, cast): + cast["time"] = str(datetime.now().isoformat()) cast["nick"], cast["ident"], cast["host"] = parsen(cast["muser"]) if dedup(self.name, cast): # Needs to be kept self.name until the dedup # function is converted to the new net, num @@ -731,7 +737,8 @@ class IRCBotFactory(ReconnectingClientFactory): if not self.relay: log("%s - %i: connection lost: %s" % (self.net, self.num, error)) sendAll("%s - %i: connection lost: %s" % (self.net, self.num, error)) - sendRelayNotification({"type": "conn", "net": self.net, "num": self.num, "status": "lost", "message": error}) + ctime = str(datetime.now().isoformat()) + sendRelayNotification({"type": "conn", "net": self.net, "num": self.num, "status": "lost", "message": error, "time": ctime}) self.retry(connector) #ReconnectingClientFactory.clientConnectionLost(self, connector, reason) @@ -744,7 +751,8 @@ class IRCBotFactory(ReconnectingClientFactory): log("%s - %i: connection failed: %s" % (self.net, self.num, error)) if not self.relay: sendAll("%s - %s: connection failed: %s" % (self.net, self.num, error)) - sendRelayNotification({"type": "conn", "net": self.net, "num": self.num, "status": "failed", "message": error}) + ctime = str(datetime.now().isoformat()) + sendRelayNotification({"type": "conn", "net": self.net, "num": self.num, "status": "failed", "message": error, "time": ctime}) self.retry(connector) #ReconnectingClientFactory.clientConnectionFailed(self, connector, reason) diff --git a/modules/monitor.py b/modules/monitor.py index e3a0590..4b3d581 100644 --- a/modules/monitor.py +++ b/modules/monitor.py @@ -19,8 +19,8 @@ def parsemeta(numName, c): # in which case, do not do this if c["type"] in ["msg", "notice", "action", "topic", "mode"]: userinfo.editUser(c["net"], c["muser"]) - if c["type"] == "mode": - userinfo.updateMode(c) + #if c["type"] == "mode": + # userinfo.updateMode(c) elif c["type"] == "nick": userinfo.renameUser(c["net"], c["nick"], c["muser"], c["user"], c["user"]+"!"+c["ident"]+"@"+c["host"]) elif c["type"] == "kick":