Remove provisioning restrictions, move all user tracking code to monitoring module, fix proper network name not being passed to the relay

This commit is contained in:
2019-08-12 21:03:47 +01:00
parent 51b89b9d05
commit 1ec0e1f7e6
5 changed files with 90 additions and 84 deletions

View File

@@ -139,7 +139,8 @@ class IRCBot(IRCClient):
del cast[i]
if "muser" in cast.keys():
cast["nick"], cast["ident"], cast["host"] = self.parsen(cast["muser"])
del cast["muser"]
#if not cast["type"] in ["nick", "kick", "quit", "part", "join"]:
# del cast["muser"]
if set(["nick", "ident", "host", "message"]).issubset(set(cast)):
if "message" in cast.keys():
if cast["ident"] == "znc" and cast["host"] == "znc.in":
@@ -181,12 +182,10 @@ class IRCBot(IRCClient):
castDup["name"] = self.name
self.event(**castDup)
if "name" not in cast.keys():
if not "name" in cast.keys():
cast["name"] = self.net
if cast["type"] in ["msg", "notice", "action"]:
userinfo.editUser(self.net, cast["nick"]+"!"+cast["ident"]+"@"+cast["host"])
count.event(self.net, cast["type"])
monitor.event(self.net, self.name, cast)
monitor.event(cast)
def privmsg(self, user, channel, msg):
self.event(type="msg", muser=user, target=channel, message=msg)
@@ -214,10 +213,8 @@ class IRCBot(IRCClient):
return newnick
def nickChanged(self, olduser, newnick):
oldnick, ident, host = self.parsen(olduser)
userinfo.renameUser(self.net, oldnick, olduser, newnick, newnick+"!"+ident+"@"+host)
self.nickname = newnick
self.event(type="self", mtype="nick", nick=oldnick, ident=ident, host=host, user=newnick)
self.event(type="self", mtype="nick", muser=olduser, user=newnick)
def irc_ERR_NICKNAMEINUSE(self, prefix, params):
self._attemptedNick = self.alterCollidedNick(self._attemptedNick)
@@ -397,59 +394,47 @@ class IRCBot(IRCClient):
lc = self._getWho[channel]
lc.stop()
del self._getWho[channel]
userinfo.delChannel(self.net, channel)
log("Can no longer cover %s, removing records" % channel)
def left(self, user, channel, message):
userinfo.delChannel(self.net, channel) # < we do not need to deduplicate this
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.botLeft(channel)
def userJoined(self, user, channel):
nick, ident, host = self.parsen(user)
userinfo.addUser(self.net, channel, nick, user)
self.event(type="join", nick=nick, ident=ident, host=host, target=channel)
self.event(type="join", muser=user, target=channel)
def userLeft(self, user, channel, message):
nick, ident, host = self.parsen(user)
userinfo.delUser(self.net, channel, nick, user)
self.event(type="part", nick=nick, ident=ident, host=host, target=channel, message=message)
self.event(type="part", muser=user, target=channel, message=message)
def userQuit(self, user, quitMessage):
nick, ident, host = self.parsen(user)
self.chanlessEvent(type="quit", nick=nick, ident=ident, host=host, message=quitMessage)
userinfo.delUserByNetwork(self.net, nick, user)
self.chanlessEvent(type="quit", muser=user, message=quitMessage)
def userKicked(self, kickee, channel, kicker, message):
nick, ident, host = self.parsen(kicker)
userinfo.editUser(self.net, kicker)
userinfo.delUserByNick(self.net, channel, kickee)
if kickee.lower == self.nickname.lower:
if kickee.lower() == self.nickname.lower():
self.botLeft(channel)
self.event(type="kick", nick=nick, ident=ident, host=host, target=channel, message=message, user=kickee)
self.event(type="kick", muser=kicker, target=channel, message=message, user=kickee)
def chanlessEvent(self, **cast):
chans = userinfo.getChansSingle(self.net, cast["nick"])
if chans == None:
self.event(**cast)
return
# getChansSingle returns all channels of the user, we only want to use
# ones we have common with them
realChans = set(chans).intersection(set(self.channels))
for i in chans:
cast["target"] = i
self.event(**cast)
def userRenamed(self, oldname, newname):
nick, ident, host = self.parsen(oldname)
self.chanlessEvent(type="nick", nick=nick, ident=ident, host=host, user=newname)
userinfo.renameUser(self.net, nick, oldname, newname, newname+"!"+ident+"@"+host)
self.chanlessEvent(type="nick", muser=oldname, user=newname)
def topicUpdated(self, user, channel, newTopic):
nick, ident, host = self.parsen(user)
userinfo.editUser(self.net, user)
self.event(type="topic", nick=nick, ident=ident, host=host, target=channel, message= newTopic)
self.event(type="topic", muser=user, target=channel, message= newTopic)
def modeChanged(self, user, channel, toset, modes, args):
nick, ident, host = self.parsen(user)
userinfo.editUser(self.net, user)
argList = list(args)
modeList = [i for i in modes]
for a, m in zip(argList, modeList):
@@ -490,7 +475,7 @@ class IRCBotFactory(ReconnectingClientFactory):
log("%s: connection lost: %s" % (self.name, error))
if not self.relay:
sendAll("%s: connection lost: %s" % (self.name, error))
sendRelayNotification(self.name, {"type": "conn", "status": "lost", "message": error})
sendRelayNotification({"type": "conn", "name": self.name, "status": "lost", "message": error})
self.retry(connector)
#ReconnectingClientFactory.clientConnectionLost(self, connector, reason)
@@ -502,7 +487,7 @@ class IRCBotFactory(ReconnectingClientFactory):
log("%s: connection failed: %s" % (self.name, error))
if not self.relay:
sendAll("%s: connection failed: %s" % (self.name, error))
sendRelayNotification(self.name, {"type": "conn", "status": "failed", "message": error})
sendRelayNotification({"type": "conn", "name": self.name, "status": "failed", "message": error})
self.retry(connector)
#ReconnectingClientFactory.clientConnectionFailed(self, connector, reason)