mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-25 04:02:45 +01:00
core: make User.channels use IRCCaseInsensitiveSet
Closes #515. This is an API breaking change!
This commit is contained in:
parent
2700e42ebf
commit
96a202acce
@ -1502,7 +1502,7 @@ Irc = IRCNetwork
|
|||||||
|
|
||||||
class User():
|
class User():
|
||||||
"""PyLink IRC user class."""
|
"""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',
|
realname='PyLink dummy client', realhost='null',
|
||||||
ip='0.0.0.0', manipulatable=False, opertype='IRC Operator'):
|
ip='0.0.0.0', manipulatable=False, opertype='IRC Operator'):
|
||||||
self.nick = nick
|
self.nick = nick
|
||||||
@ -1515,6 +1515,7 @@ class User():
|
|||||||
self.realname = realname
|
self.realname = realname
|
||||||
self.modes = set() # Tracks user modes
|
self.modes = set() # Tracks user modes
|
||||||
self.server = server
|
self.server = server
|
||||||
|
self.irc = irc
|
||||||
|
|
||||||
# Tracks PyLink identification status
|
# Tracks PyLink identification status
|
||||||
self.account = ''
|
self.account = ''
|
||||||
@ -1526,7 +1527,7 @@ class User():
|
|||||||
self.services_account = ''
|
self.services_account = ''
|
||||||
|
|
||||||
# Tracks channels the user is in
|
# Tracks channels the user is in
|
||||||
self.channels = set()
|
self.channels = structures.IRCCaseInsensitiveSet(self.irc)
|
||||||
|
|
||||||
# Tracks away message status
|
# Tracks away message status
|
||||||
self.away = ''
|
self.away = ''
|
||||||
|
@ -103,7 +103,7 @@ class ClientbotWrapperProtocol(IRCCommonProtocol):
|
|||||||
|
|
||||||
f('NICK %s' % nick)
|
f('NICK %s' % nick)
|
||||||
f('USER %s 8 * :%s' % (ident, realname))
|
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())
|
ident=ident, realname=realname, host=self.hostname())
|
||||||
self.users[self.pseudoclient.uid] = self.pseudoclient
|
self.users[self.pseudoclient.uid] = self.pseudoclient
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ class ClientbotWrapperProtocol(IRCCommonProtocol):
|
|||||||
ts = ts or int(time.time())
|
ts = ts or int(time.time())
|
||||||
|
|
||||||
log.debug('(%s) spawn_client stub called, saving nick %s as PUID %s', self.name, nick, uid)
|
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)
|
manipulatable=manipulatable, realhost=realhost, ip=ip)
|
||||||
self.servers[server].users.add(uid)
|
self.servers[server].users.add(uid)
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ class HybridProtocol(TS6Protocol):
|
|||||||
realname = realname or conf.conf['bot']['realname']
|
realname = realname or conf.conf['bot']['realname']
|
||||||
realhost = realhost or host
|
realhost = realhost or host
|
||||||
raw_modes = self.join_modes(modes)
|
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)
|
realhost=realhost, ip=ip, manipulatable=manipulatable)
|
||||||
self.apply_modes(uid, modes)
|
self.apply_modes(uid, modes)
|
||||||
self.servers[server].users.add(uid)
|
self.servers[server].users.add(uid)
|
||||||
@ -199,7 +199,7 @@ class HybridProtocol(TS6Protocol):
|
|||||||
'host=%s realname=%s ip=%s', self.name, nick, ts, uid,
|
'host=%s realname=%s ip=%s', self.name, nick, ts, uid,
|
||||||
ident, host, realname, ip)
|
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])
|
parsedmodes = self.parse_modes(uid, [modes])
|
||||||
log.debug('(%s) handle_uid: Applying modes %s for %s', self.name, parsedmodes, uid)
|
log.debug('(%s) handle_uid: Applying modes %s for %s', self.name, parsedmodes, uid)
|
||||||
|
@ -56,7 +56,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
realname = realname or conf.conf['bot']['realname']
|
realname = realname or conf.conf['bot']['realname']
|
||||||
realhost = realhost or host
|
realhost = realhost or host
|
||||||
raw_modes = self.join_modes(modes)
|
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)
|
realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype)
|
||||||
|
|
||||||
self.apply_modes(uid, modes)
|
self.apply_modes(uid, modes)
|
||||||
@ -587,7 +587,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
uid, ts, nick, realhost, host, ident, ip = args[0:7]
|
uid, ts, nick, realhost, host, ident, ip = args[0:7]
|
||||||
self._check_nick_collision(nick)
|
self._check_nick_collision(nick)
|
||||||
realname = args[-1]
|
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]])
|
parsedmodes = self.parse_modes(uid, [args[8], args[9]])
|
||||||
self.apply_modes(uid, parsedmodes)
|
self.apply_modes(uid, parsedmodes)
|
||||||
|
@ -87,7 +87,7 @@ class NgIRCdProtocol(IRCS2SProtocol):
|
|||||||
realname = realname or conf.conf['bot']['realname']
|
realname = realname or conf.conf['bot']['realname']
|
||||||
|
|
||||||
uid = self._uidgen.next_uid(prefix=nick)
|
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)
|
manipulatable=manipulatable, opertype=opertype, realhost=host)
|
||||||
|
|
||||||
self.apply_modes(uid, modes)
|
self.apply_modes(uid, modes)
|
||||||
@ -445,7 +445,7 @@ class NgIRCdProtocol(IRCS2SProtocol):
|
|||||||
realname = args[-1]
|
realname = args[-1]
|
||||||
|
|
||||||
ts = int(time.time())
|
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]])
|
parsedmodes = self.parse_modes(uid, [args[5]])
|
||||||
self.apply_modes(uid, parsedmodes)
|
self.apply_modes(uid, parsedmodes)
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ class P10Protocol(IRCS2SProtocol):
|
|||||||
raw_modes = self.join_modes(modes)
|
raw_modes = self.join_modes(modes)
|
||||||
|
|
||||||
# Initialize an User instance
|
# 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)
|
realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype)
|
||||||
|
|
||||||
# Fill in modes and add it to our users index
|
# 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,
|
'host=%s realname=%s realhost=%s ip=%s', self.name, nick, ts, uid,
|
||||||
ident, host, realname, realhost, ip)
|
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)
|
self.servers[source].users.add(uid)
|
||||||
|
|
||||||
# https://github.com/evilnet/nefarious2/blob/master/doc/p10.txt#L708
|
# https://github.com/evilnet/nefarious2/blob/master/doc/p10.txt#L708
|
||||||
|
@ -72,7 +72,7 @@ class RatboxProtocol(TS6Protocol):
|
|||||||
orig_realhost = realhost
|
orig_realhost = realhost
|
||||||
realhost = realhost or host
|
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)
|
realhost=realhost, ip=ip, manipulatable=manipulatable)
|
||||||
self.apply_modes(uid, modes)
|
self.apply_modes(uid, modes)
|
||||||
self.servers[server].users.add(uid)
|
self.servers[server].users.add(uid)
|
||||||
|
@ -55,7 +55,7 @@ class TS6Protocol(TS6BaseProtocol):
|
|||||||
realname = realname or conf.conf['bot']['realname']
|
realname = realname or conf.conf['bot']['realname']
|
||||||
realhost = realhost or host
|
realhost = realhost or host
|
||||||
raw_modes = self.join_modes(modes)
|
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)
|
realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype)
|
||||||
|
|
||||||
self.apply_modes(uid, modes)
|
self.apply_modes(uid, modes)
|
||||||
@ -548,7 +548,7 @@ class TS6Protocol(TS6BaseProtocol):
|
|||||||
if ip == '0': # IP was invalid; something used for services.
|
if ip == '0': # IP was invalid; something used for services.
|
||||||
ip = '0.0.0.0'
|
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])
|
parsedmodes = self.parse_modes(uid, [modes])
|
||||||
log.debug('Applying modes %s for %s', parsedmodes, uid)
|
log.debug('Applying modes %s for %s', parsedmodes, uid)
|
||||||
|
@ -69,7 +69,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
modes |= {('+x', None), ('+t', None)}
|
modes |= {('+x', None), ('+t', None)}
|
||||||
|
|
||||||
raw_modes = self.join_modes(modes)
|
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)
|
realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype)
|
||||||
self.apply_modes(uid, modes)
|
self.apply_modes(uid, modes)
|
||||||
self.servers[server].users.add(uid)
|
self.servers[server].users.add(uid)
|
||||||
@ -415,7 +415,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
|
|
||||||
realname = args[-1]
|
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)
|
self.servers[numeric].users.add(uid)
|
||||||
|
|
||||||
# Handle user modes
|
# Handle user modes
|
||||||
|
Loading…
Reference in New Issue
Block a user