diff --git a/classes.py b/classes.py index b83ea26..7bbc66f 100644 --- a/classes.py +++ b/classes.py @@ -1502,7 +1502,7 @@ Irc = IRCNetwork class User(): """PyLink IRC user class.""" - def __init__(self, nick, ts, uid, server, ident='null', host='null', + def __init__(self, irc, nick, ts, uid, server, ident='null', host='null', realname='PyLink dummy client', realhost='null', ip='0.0.0.0', manipulatable=False, opertype='IRC Operator'): self.nick = nick @@ -1515,6 +1515,7 @@ class User(): self.realname = realname self.modes = set() # Tracks user modes self.server = server + self.irc = irc # Tracks PyLink identification status self.account = '' @@ -1526,7 +1527,7 @@ class User(): self.services_account = '' # Tracks channels the user is in - self.channels = set() + self.channels = structures.IRCCaseInsensitiveSet(self.irc) # Tracks away message status self.away = '' diff --git a/protocols/clientbot.py b/protocols/clientbot.py index 9b6fb27..15678a5 100644 --- a/protocols/clientbot.py +++ b/protocols/clientbot.py @@ -103,7 +103,7 @@ class ClientbotWrapperProtocol(IRCCommonProtocol): f('NICK %s' % nick) f('USER %s 8 * :%s' % (ident, realname)) - self.pseudoclient = User(nick, int(time.time()), self.uidgen.next_uid(prefix='@ClientbotInternal'), self.sid, + self.pseudoclient = User(self, nick, int(time.time()), self.uidgen.next_uid(prefix='@ClientbotInternal'), self.sid, ident=ident, realname=realname, host=self.hostname()) self.users[self.pseudoclient.uid] = self.pseudoclient @@ -121,7 +121,7 @@ class ClientbotWrapperProtocol(IRCCommonProtocol): ts = ts or int(time.time()) log.debug('(%s) spawn_client stub called, saving nick %s as PUID %s', self.name, nick, uid) - u = self.users[uid] = User(nick, ts, uid, server, ident=ident, host=host, realname=realname, + u = self.users[uid] = User(self, nick, ts, uid, server, ident=ident, host=host, realname=realname, manipulatable=manipulatable, realhost=realhost, ip=ip) self.servers[server].users.add(uid) diff --git a/protocols/hybrid.py b/protocols/hybrid.py index 2d2a8f0..34a4930 100644 --- a/protocols/hybrid.py +++ b/protocols/hybrid.py @@ -113,7 +113,7 @@ class HybridProtocol(TS6Protocol): realname = realname or conf.conf['bot']['realname'] realhost = realhost or host raw_modes = self.join_modes(modes) - u = self.users[uid] = User(nick, ts, uid, server, ident=ident, host=host, realname=realname, + u = self.users[uid] = User(self, nick, ts, uid, server, ident=ident, host=host, realname=realname, realhost=realhost, ip=ip, manipulatable=manipulatable) self.apply_modes(uid, modes) self.servers[server].users.add(uid) @@ -199,7 +199,7 @@ class HybridProtocol(TS6Protocol): 'host=%s realname=%s ip=%s', self.name, nick, ts, uid, ident, host, realname, ip) - self.users[uid] = User(nick, ts, uid, numeric, ident, host, realname, host, ip) + self.users[uid] = User(self, nick, ts, uid, numeric, ident, host, realname, host, ip) parsedmodes = self.parse_modes(uid, [modes]) log.debug('(%s) handle_uid: Applying modes %s for %s', self.name, parsedmodes, uid) diff --git a/protocols/inspircd.py b/protocols/inspircd.py index f69d5a8..c94458d 100644 --- a/protocols/inspircd.py +++ b/protocols/inspircd.py @@ -56,7 +56,7 @@ class InspIRCdProtocol(TS6BaseProtocol): realname = realname or conf.conf['bot']['realname'] realhost = realhost or host raw_modes = self.join_modes(modes) - u = self.users[uid] = User(nick, ts, uid, server, ident=ident, host=host, realname=realname, + u = self.users[uid] = User(self, nick, ts, uid, server, ident=ident, host=host, realname=realname, realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype) self.apply_modes(uid, modes) @@ -587,7 +587,7 @@ class InspIRCdProtocol(TS6BaseProtocol): uid, ts, nick, realhost, host, ident, ip = args[0:7] self._check_nick_collision(nick) realname = args[-1] - self.users[uid] = userobj = User(nick, ts, uid, numeric, ident, host, realname, realhost, ip) + self.users[uid] = userobj = User(self, nick, ts, uid, numeric, ident, host, realname, realhost, ip) parsedmodes = self.parse_modes(uid, [args[8], args[9]]) self.apply_modes(uid, parsedmodes) diff --git a/protocols/ngircd.py b/protocols/ngircd.py index ef2a44a..cf0dbab 100644 --- a/protocols/ngircd.py +++ b/protocols/ngircd.py @@ -87,7 +87,7 @@ class NgIRCdProtocol(IRCS2SProtocol): realname = realname or conf.conf['bot']['realname'] uid = self._uidgen.next_uid(prefix=nick) - userobj = self.users[uid] = User(nick, ts or int(time.time()), uid, server, ident=ident, host=host, realname=realname, + userobj = self.users[uid] = User(self, nick, ts or int(time.time()), uid, server, ident=ident, host=host, realname=realname, manipulatable=manipulatable, opertype=opertype, realhost=host) self.apply_modes(uid, modes) @@ -445,7 +445,7 @@ class NgIRCdProtocol(IRCS2SProtocol): realname = args[-1] ts = int(time.time()) - self.users[uid] = User(nick, ts, uid, source, ident=ident, host=host, realname=realname, realhost=host) + self.users[uid] = User(self, nick, ts, uid, source, ident=ident, host=host, realname=realname, realhost=host) parsedmodes = self.parse_modes(uid, [args[5]]) self.apply_modes(uid, parsedmodes) diff --git a/protocols/p10.py b/protocols/p10.py index 8ded65f..35bcc72 100644 --- a/protocols/p10.py +++ b/protocols/p10.py @@ -279,7 +279,7 @@ class P10Protocol(IRCS2SProtocol): raw_modes = self.join_modes(modes) # Initialize an User instance - u = self.users[uid] = User(nick, ts, uid, server, ident=ident, host=host, realname=realname, + u = self.users[uid] = User(self, nick, ts, uid, server, ident=ident, host=host, realname=realname, realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype) # Fill in modes and add it to our users index @@ -858,7 +858,7 @@ class P10Protocol(IRCS2SProtocol): 'host=%s realname=%s realhost=%s ip=%s', self.name, nick, ts, uid, ident, host, realname, realhost, ip) - uobj = self.users[uid] = User(nick, ts, uid, source, ident, host, realname, realhost, ip) + uobj = self.users[uid] = User(self, nick, ts, uid, source, ident, host, realname, realhost, ip) self.servers[source].users.add(uid) # https://github.com/evilnet/nefarious2/blob/master/doc/p10.txt#L708 diff --git a/protocols/ratbox.py b/protocols/ratbox.py index aa9b759..8271d2d 100644 --- a/protocols/ratbox.py +++ b/protocols/ratbox.py @@ -72,7 +72,7 @@ class RatboxProtocol(TS6Protocol): orig_realhost = realhost realhost = realhost or host - u = self.users[uid] = User(nick, ts, uid, server, ident=ident, host=host, realname=realname, + u = self.users[uid] = User(self, nick, ts, uid, server, ident=ident, host=host, realname=realname, realhost=realhost, ip=ip, manipulatable=manipulatable) self.apply_modes(uid, modes) self.servers[server].users.add(uid) diff --git a/protocols/ts6.py b/protocols/ts6.py index 8e5a9db..7120ea9 100644 --- a/protocols/ts6.py +++ b/protocols/ts6.py @@ -55,7 +55,7 @@ class TS6Protocol(TS6BaseProtocol): realname = realname or conf.conf['bot']['realname'] realhost = realhost or host raw_modes = self.join_modes(modes) - u = self.users[uid] = User(nick, ts, uid, server, ident=ident, host=host, realname=realname, + u = self.users[uid] = User(self, nick, ts, uid, server, ident=ident, host=host, realname=realname, realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype) self.apply_modes(uid, modes) @@ -548,7 +548,7 @@ class TS6Protocol(TS6BaseProtocol): if ip == '0': # IP was invalid; something used for services. ip = '0.0.0.0' - self.users[uid] = User(nick, ts, uid, numeric, ident, host, realname, realhost, ip) + self.users[uid] = User(self, nick, ts, uid, numeric, ident, host, realname, realhost, ip) parsedmodes = self.parse_modes(uid, [modes]) log.debug('Applying modes %s for %s', parsedmodes, uid) diff --git a/protocols/unreal.py b/protocols/unreal.py index 8691b75..8538aac 100644 --- a/protocols/unreal.py +++ b/protocols/unreal.py @@ -69,7 +69,7 @@ class UnrealProtocol(TS6BaseProtocol): modes |= {('+x', None), ('+t', None)} raw_modes = self.join_modes(modes) - u = self.users[uid] = User(nick, ts, uid, server, ident=ident, host=host, realname=realname, + u = self.users[uid] = User(self, nick, ts, uid, server, ident=ident, host=host, realname=realname, realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype) self.apply_modes(uid, modes) self.servers[server].users.add(uid) @@ -415,7 +415,7 @@ class UnrealProtocol(TS6BaseProtocol): realname = args[-1] - self.users[uid] = User(nick, ts, uid, numeric, ident, host, realname, realhost, ip) + self.users[uid] = User(self, nick, ts, uid, numeric, ident, host, realname, realhost, ip) self.servers[numeric].users.add(uid) # Handle user modes