mirror of
https://github.com/jlu5/PyLink.git
synced 2025-02-17 14:01:03 +01:00
protocols: migrate to irc.parseModes/applyModes (#199)
This commit is contained in:
parent
84822fb1d6
commit
a8fc9428cf
@ -111,7 +111,7 @@ class HybridProtocol(TS6Protocol):
|
|||||||
raw_modes = utils.joinModes(modes)
|
raw_modes = utils.joinModes(modes)
|
||||||
u = self.irc.users[uid] = IrcUser(nick, ts, uid, ident=ident, host=host, realname=realname,
|
u = self.irc.users[uid] = IrcUser(nick, ts, uid, ident=ident, host=host, realname=realname,
|
||||||
realhost=realhost, ip=ip, manipulatable=manipulatable)
|
realhost=realhost, ip=ip, manipulatable=manipulatable)
|
||||||
utils.applyModes(self.irc, uid, modes)
|
self.irc.applyModes(uid, modes)
|
||||||
self.irc.servers[server].users.add(uid)
|
self.irc.servers[server].users.add(uid)
|
||||||
self._send(server, "UID {nick} 1 {ts} {modes} {ident} {host} {ip} {uid} "
|
self._send(server, "UID {nick} 1 {ts} {modes} {ident} {host} {ip} {uid} "
|
||||||
"* :{realname}".format(ts=ts, host=host,
|
"* :{realname}".format(ts=ts, host=host,
|
||||||
@ -182,9 +182,9 @@ class HybridProtocol(TS6Protocol):
|
|||||||
|
|
||||||
self.irc.users[uid] = IrcUser(nick, ts, uid, ident, host, realname, host, ip)
|
self.irc.users[uid] = IrcUser(nick, ts, uid, ident, host, realname, host, ip)
|
||||||
|
|
||||||
parsedmodes = utils.parseModes(self.irc, uid, [modes])
|
parsedmodes = self.irc.parseModes(uid, [modes])
|
||||||
log.debug('(%s) handle_uid: Applying modes %s for %s', self.irc.name, parsedmodes, uid)
|
log.debug('(%s) handle_uid: Applying modes %s for %s', self.irc.name, parsedmodes, uid)
|
||||||
utils.applyModes(self.irc, uid, parsedmodes)
|
self.irc.applyModes(uid, parsedmodes)
|
||||||
self.irc.servers[numeric].users.add(uid)
|
self.irc.servers[numeric].users.add(uid)
|
||||||
|
|
||||||
# Call the OPERED UP hook if +o is being added to the mode list.
|
# Call the OPERED UP hook if +o is being added to the mode list.
|
||||||
@ -221,7 +221,7 @@ class HybridProtocol(TS6Protocol):
|
|||||||
target = args[0]
|
target = args[0]
|
||||||
ts = args[1]
|
ts = args[1]
|
||||||
modes = args[2:]
|
modes = args[2:]
|
||||||
parsedmodes = utils.parseModes(self.irc, target, modes)
|
parsedmodes = self.irc.parseModes(target, modes)
|
||||||
|
|
||||||
for modepair in parsedmodes:
|
for modepair in parsedmodes:
|
||||||
if modepair[0] == '+d':
|
if modepair[0] == '+d':
|
||||||
@ -259,7 +259,7 @@ class HybridProtocol(TS6Protocol):
|
|||||||
parsedmodes.remove(modepair)
|
parsedmodes.remove(modepair)
|
||||||
|
|
||||||
if parsedmodes:
|
if parsedmodes:
|
||||||
utils.applyModes(self.irc, target, parsedmodes)
|
self.irc.applyModes(target, parsedmodes)
|
||||||
|
|
||||||
return {'target': target, 'modes': parsedmodes}
|
return {'target': target, 'modes': parsedmodes}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
u = self.irc.users[uid] = IrcUser(nick, ts, uid, ident=ident, host=host, realname=realname,
|
u = self.irc.users[uid] = IrcUser(nick, ts, uid, ident=ident, host=host, realname=realname,
|
||||||
realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype)
|
realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype)
|
||||||
|
|
||||||
utils.applyModes(self.irc, uid, modes)
|
self.irc.applyModes(uid, modes)
|
||||||
self.irc.servers[server].users.add(uid)
|
self.irc.servers[server].users.add(uid)
|
||||||
|
|
||||||
self._send(server, "UID {uid} {ts} {nick} {realhost} {host} {ident} {ip}"
|
self._send(server, "UID {uid} {ts} {nick} {realhost} {host} {ident} {ip}"
|
||||||
@ -132,7 +132,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
log.debug("(%s) sjoin: KeyError trying to add %r to %r's channel list?", self.irc.name, channel, user)
|
log.debug("(%s) sjoin: KeyError trying to add %r to %r's channel list?", self.irc.name, channel, user)
|
||||||
if ts <= orig_ts:
|
if ts <= orig_ts:
|
||||||
# Only save our prefix modes in the channel state if our TS is lower than or equal to theirs.
|
# Only save our prefix modes in the channel state if our TS is lower than or equal to theirs.
|
||||||
utils.applyModes(self.irc, channel, changedmodes)
|
self.irc.applyModes(channel, changedmodes)
|
||||||
namelist = ' '.join(namelist)
|
namelist = ' '.join(namelist)
|
||||||
self._send(server, "FJOIN {channel} {ts} {modes} :{users}".format(
|
self._send(server, "FJOIN {channel} {ts} {modes} :{users}".format(
|
||||||
ts=ts, users=namelist, channel=channel,
|
ts=ts, users=namelist, channel=channel,
|
||||||
@ -177,7 +177,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
# https://github.com/inspircd/inspircd/blob/master/src/modules/m_spanningtree/opertype.cpp#L26-L28
|
# https://github.com/inspircd/inspircd/blob/master/src/modules/m_spanningtree/opertype.cpp#L26-L28
|
||||||
# Servers need a special command to set umode +o on people.
|
# Servers need a special command to set umode +o on people.
|
||||||
self._operUp(target)
|
self._operUp(target)
|
||||||
utils.applyModes(self.irc, target, modes)
|
self.irc.applyModes(target, modes)
|
||||||
joinedmodes = utils.joinModes(modes)
|
joinedmodes = utils.joinModes(modes)
|
||||||
if utils.isChannel(target):
|
if utils.isChannel(target):
|
||||||
ts = ts or self.irc.channels[utils.toLower(self.irc, target)].ts
|
ts = ts or self.irc.channels[utils.toLower(self.irc, target)].ts
|
||||||
@ -491,8 +491,8 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
self.updateTS(channel, their_ts)
|
self.updateTS(channel, their_ts)
|
||||||
|
|
||||||
modestring = args[2:-1] or args[2]
|
modestring = args[2:-1] or args[2]
|
||||||
parsedmodes = utils.parseModes(self.irc, channel, modestring)
|
parsedmodes = self.irc.parseModes(channel, modestring)
|
||||||
utils.applyModes(self.irc, channel, parsedmodes)
|
self.irc.applyModes(channel, parsedmodes)
|
||||||
namelist = []
|
namelist = []
|
||||||
for user in userlist:
|
for user in userlist:
|
||||||
modeprefix, user = user.split(',', 1)
|
modeprefix, user = user.split(',', 1)
|
||||||
@ -506,7 +506,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
namelist.append(user)
|
namelist.append(user)
|
||||||
self.irc.users[user].channels.add(channel)
|
self.irc.users[user].channels.add(channel)
|
||||||
if their_ts <= our_ts:
|
if their_ts <= our_ts:
|
||||||
utils.applyModes(self.irc, channel, [('+%s' % mode, user) for mode in modeprefix])
|
self.irc.applyModes(channel, [('+%s' % mode, user) for mode in modeprefix])
|
||||||
self.irc.channels[channel].users.add(user)
|
self.irc.channels[channel].users.add(user)
|
||||||
return {'channel': channel, 'users': namelist, 'modes': parsedmodes, 'ts': their_ts}
|
return {'channel': channel, 'users': namelist, 'modes': parsedmodes, 'ts': their_ts}
|
||||||
|
|
||||||
@ -516,9 +516,9 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
uid, ts, nick, realhost, host, ident, ip = args[0:7]
|
uid, ts, nick, realhost, host, ident, ip = args[0:7]
|
||||||
realname = args[-1]
|
realname = args[-1]
|
||||||
self.irc.users[uid] = IrcUser(nick, ts, uid, ident, host, realname, realhost, ip)
|
self.irc.users[uid] = IrcUser(nick, ts, uid, ident, host, realname, realhost, ip)
|
||||||
parsedmodes = utils.parseModes(self.irc, uid, [args[8], args[9]])
|
parsedmodes = self.irc.parseModes(uid, [args[8], args[9]])
|
||||||
log.debug('Applying modes %s for %s', parsedmodes, uid)
|
log.debug('Applying modes %s for %s', parsedmodes, uid)
|
||||||
utils.applyModes(self.irc, uid, parsedmodes)
|
self.irc.applyModes(uid, parsedmodes)
|
||||||
self.irc.servers[numeric].users.add(uid)
|
self.irc.servers[numeric].users.add(uid)
|
||||||
return {'uid': uid, 'ts': ts, 'nick': nick, 'realhost': realhost, 'host': host, 'ident': ident, 'ip': ip}
|
return {'uid': uid, 'ts': ts, 'nick': nick, 'realhost': realhost, 'host': host, 'ident': ident, 'ip': ip}
|
||||||
|
|
||||||
@ -555,8 +555,8 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
channel = utils.toLower(self.irc, args[0])
|
channel = utils.toLower(self.irc, args[0])
|
||||||
oldobj = self.irc.channels[channel].deepcopy()
|
oldobj = self.irc.channels[channel].deepcopy()
|
||||||
modes = args[2:]
|
modes = args[2:]
|
||||||
changedmodes = utils.parseModes(self.irc, channel, modes)
|
changedmodes = self.irc.parseModes(channel, modes)
|
||||||
utils.applyModes(self.irc, channel, changedmodes)
|
self.irc.applyModes(channel, changedmodes)
|
||||||
ts = int(args[1])
|
ts = int(args[1])
|
||||||
return {'target': channel, 'modes': changedmodes, 'ts': ts,
|
return {'target': channel, 'modes': changedmodes, 'ts': ts,
|
||||||
'oldchan': oldobj}
|
'oldchan': oldobj}
|
||||||
@ -568,8 +568,8 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
# <- :70MAAAAAA MODE 70MAAAAAA -i+xc
|
# <- :70MAAAAAA MODE 70MAAAAAA -i+xc
|
||||||
target = args[0]
|
target = args[0]
|
||||||
modestrings = args[1:]
|
modestrings = args[1:]
|
||||||
changedmodes = utils.parseModes(self.irc, target, modestrings)
|
changedmodes = self.irc.parseModes(target, modestrings)
|
||||||
utils.applyModes(self.irc, target, changedmodes)
|
self.irc.applyModes(target, changedmodes)
|
||||||
return {'target': target, 'modes': changedmodes}
|
return {'target': target, 'modes': changedmodes}
|
||||||
|
|
||||||
def handle_idle(self, numeric, command, args):
|
def handle_idle(self, numeric, command, args):
|
||||||
@ -636,7 +636,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
|
|||||||
# <- :70MAAAAAB OPERTYPE Network_Owner
|
# <- :70MAAAAAB OPERTYPE Network_Owner
|
||||||
omode = [('+o', None)]
|
omode = [('+o', None)]
|
||||||
self.irc.users[numeric].opertype = opertype = args[0].replace("_", " ")
|
self.irc.users[numeric].opertype = opertype = args[0].replace("_", " ")
|
||||||
utils.applyModes(self.irc, numeric, omode)
|
self.irc.applyModes(numeric, omode)
|
||||||
# OPERTYPE is essentially umode +o and metadata in one command;
|
# OPERTYPE is essentially umode +o and metadata in one command;
|
||||||
# we'll call that too.
|
# we'll call that too.
|
||||||
self.irc.callHooks([numeric, 'CLIENT_OPERED', {'text': opertype}])
|
self.irc.callHooks([numeric, 'CLIENT_OPERED', {'text': opertype}])
|
||||||
|
@ -270,7 +270,7 @@ class P10Protocol(Protocol):
|
|||||||
opertype=opertype)
|
opertype=opertype)
|
||||||
|
|
||||||
# Fill in modes and add it to our users index
|
# Fill in modes and add it to our users index
|
||||||
utils.applyModes(self.irc, uid, modes)
|
self.irc.applyModes(uid, modes)
|
||||||
self.irc.servers[server].users.add(uid)
|
self.irc.servers[server].users.add(uid)
|
||||||
|
|
||||||
# Encode IPs when sending
|
# Encode IPs when sending
|
||||||
@ -377,7 +377,7 @@ class P10Protocol(Protocol):
|
|||||||
(not self.irc.isInternalServer(numeric)):
|
(not self.irc.isInternalServer(numeric)):
|
||||||
raise LookupError('No such PyLink client/server exists.')
|
raise LookupError('No such PyLink client/server exists.')
|
||||||
|
|
||||||
utils.applyModes(self.irc, target, modes)
|
self.irc.applyModes(target, modes)
|
||||||
modes = list(modes)
|
modes = list(modes)
|
||||||
|
|
||||||
# According to the P10 specification:
|
# According to the P10 specification:
|
||||||
@ -533,7 +533,7 @@ class P10Protocol(Protocol):
|
|||||||
|
|
||||||
if ts <= orig_ts:
|
if ts <= orig_ts:
|
||||||
# Only save our prefix modes in the channel state if our TS is lower than or equal to theirs.
|
# Only save our prefix modes in the channel state if our TS is lower than or equal to theirs.
|
||||||
utils.applyModes(self.irc, channel, changedmodes)
|
self.irc.applyModes(channel, changedmodes)
|
||||||
|
|
||||||
def spawnServer(self, name, sid=None, uplink=None, desc=None, endburst_delay=0):
|
def spawnServer(self, name, sid=None, uplink=None, desc=None, endburst_delay=0):
|
||||||
"""
|
"""
|
||||||
@ -623,7 +623,7 @@ class P10Protocol(Protocol):
|
|||||||
self._send(self.irc.sid, 'FA %s %s' % (target, text))
|
self._send(self.irc.sid, 'FA %s %s' % (target, text))
|
||||||
# Save the host change as a user mode (this is what P10 does),
|
# Save the host change as a user mode (this is what P10 does),
|
||||||
# so further host checks work.
|
# so further host checks work.
|
||||||
utils.applyModes(self.irc, target, [('+f', text)])
|
self.irc.applyModes(target, [('+f', text)])
|
||||||
|
|
||||||
# P10 cloaks aren't as simple as just replacing the displayed host with the one we're
|
# P10 cloaks aren't as simple as just replacing the displayed host with the one we're
|
||||||
# sending. Check for cloak changes properly.
|
# sending. Check for cloak changes properly.
|
||||||
@ -786,8 +786,8 @@ class P10Protocol(Protocol):
|
|||||||
# parameters attached.
|
# parameters attached.
|
||||||
if args[5].startswith('+'):
|
if args[5].startswith('+'):
|
||||||
modes = args[5:-3]
|
modes = args[5:-3]
|
||||||
parsedmodes = utils.parseModes(self.irc, uid, modes)
|
parsedmodes = self.irc.parseModes(uid, modes)
|
||||||
utils.applyModes(self.irc, uid, parsedmodes)
|
self.irc.applyModes(uid, parsedmodes)
|
||||||
|
|
||||||
for modepair in parsedmodes:
|
for modepair in parsedmodes:
|
||||||
if modepair[0][-1] == 'r':
|
if modepair[0][-1] == 'r':
|
||||||
@ -952,7 +952,7 @@ class P10Protocol(Protocol):
|
|||||||
# If no modes are given, this will simply be empty.
|
# If no modes are given, this will simply be empty.
|
||||||
modestring = args[2:-1]
|
modestring = args[2:-1]
|
||||||
if modestring:
|
if modestring:
|
||||||
parsedmodes = utils.parseModes(self.irc, channel, modestring)
|
parsedmodes = self.irc.parseModes(channel, modestring)
|
||||||
else:
|
else:
|
||||||
parsedmodes = []
|
parsedmodes = []
|
||||||
|
|
||||||
@ -960,7 +960,7 @@ class P10Protocol(Protocol):
|
|||||||
parsedmodes.extend(bans)
|
parsedmodes.extend(bans)
|
||||||
|
|
||||||
if parsedmodes:
|
if parsedmodes:
|
||||||
utils.applyModes(self.irc, channel, parsedmodes)
|
self.irc.applyModes(channel, parsedmodes)
|
||||||
|
|
||||||
namelist = []
|
namelist = []
|
||||||
log.debug('(%s) handle_sjoin: got userlist %r for %r', self.irc.name, userlist, channel)
|
log.debug('(%s) handle_sjoin: got userlist %r for %r', self.irc.name, userlist, channel)
|
||||||
@ -991,7 +991,7 @@ class P10Protocol(Protocol):
|
|||||||
self.irc.users[user].channels.add(channel)
|
self.irc.users[user].channels.add(channel)
|
||||||
|
|
||||||
if their_ts <= our_ts:
|
if their_ts <= our_ts:
|
||||||
utils.applyModes(self.irc, channel, [('+%s' % mode, user) for mode in prefixes])
|
self.irc.applyModes(channel, [('+%s' % mode, user) for mode in prefixes])
|
||||||
|
|
||||||
self.irc.channels[channel].users.add(user)
|
self.irc.channels[channel].users.add(user)
|
||||||
|
|
||||||
@ -1060,8 +1060,8 @@ class P10Protocol(Protocol):
|
|||||||
target = utils.toLower(self.irc, target)
|
target = utils.toLower(self.irc, target)
|
||||||
|
|
||||||
modestrings = args[1:]
|
modestrings = args[1:]
|
||||||
changedmodes = utils.parseModes(self.irc, target, modestrings)
|
changedmodes = self.irc.parseModes(target, modestrings)
|
||||||
utils.applyModes(self.irc, target, changedmodes)
|
self.irc.applyModes(target, changedmodes)
|
||||||
|
|
||||||
# Call the CLIENT_OPERED hook if +o is being set.
|
# Call the CLIENT_OPERED hook if +o is being set.
|
||||||
if ('+o', None) in changedmodes and target in self.irc.users:
|
if ('+o', None) in changedmodes and target in self.irc.users:
|
||||||
@ -1236,7 +1236,7 @@ class P10Protocol(Protocol):
|
|||||||
# Mode does not take an argument when unsetting.
|
# Mode does not take an argument when unsetting.
|
||||||
changedmodes.append(('-%s' % modechar, None))
|
changedmodes.append(('-%s' % modechar, None))
|
||||||
|
|
||||||
utils.applyModes(self.irc, channel, changedmodes)
|
self.irc.applyModes(channel, changedmodes)
|
||||||
return {'target': channel, 'modes': changedmodes, 'oldchan': oldobj}
|
return {'target': channel, 'modes': changedmodes, 'oldchan': oldobj}
|
||||||
|
|
||||||
def handle_account(self, numeric, command, args):
|
def handle_account(self, numeric, command, args):
|
||||||
@ -1281,7 +1281,7 @@ class P10Protocol(Protocol):
|
|||||||
text = args[1]
|
text = args[1]
|
||||||
|
|
||||||
# Assume a usermode +f change, and then update the cloak checking.
|
# Assume a usermode +f change, and then update the cloak checking.
|
||||||
utils.applyModes(self.irc, target, [('+f', text)])
|
self.irc.applyModes(target, [('+f', text)])
|
||||||
|
|
||||||
self.checkCloakChange(target)
|
self.checkCloakChange(target)
|
||||||
# We don't need to send any hooks here, checkCloakChange does that for us.
|
# We don't need to send any hooks here, checkCloakChange does that for us.
|
||||||
|
@ -54,7 +54,7 @@ class TS6Protocol(TS6BaseProtocol):
|
|||||||
u = self.irc.users[uid] = IrcUser(nick, ts, uid, ident=ident, host=host, realname=realname,
|
u = self.irc.users[uid] = IrcUser(nick, ts, uid, ident=ident, host=host, realname=realname,
|
||||||
realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype)
|
realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype)
|
||||||
|
|
||||||
utils.applyModes(self.irc, uid, modes)
|
self.irc.applyModes(uid, modes)
|
||||||
self.irc.servers[server].users.add(uid)
|
self.irc.servers[server].users.add(uid)
|
||||||
|
|
||||||
self._send(server, "EUID {nick} 1 {ts} {modes} {ident} {host} {ip} {uid} "
|
self._send(server, "EUID {nick} 1 {ts} {modes} {ident} {host} {ip} {uid} "
|
||||||
@ -139,7 +139,7 @@ class TS6Protocol(TS6BaseProtocol):
|
|||||||
self.irc.channels[channel].users.update(uids)
|
self.irc.channels[channel].users.update(uids)
|
||||||
if ts <= orig_ts:
|
if ts <= orig_ts:
|
||||||
# Only save our prefix modes in the channel state if our TS is lower than or equal to theirs.
|
# Only save our prefix modes in the channel state if our TS is lower than or equal to theirs.
|
||||||
utils.applyModes(self.irc, channel, changedmodes)
|
self.irc.applyModes(channel, changedmodes)
|
||||||
|
|
||||||
def mode(self, numeric, target, modes, ts=None):
|
def mode(self, numeric, target, modes, ts=None):
|
||||||
"""Sends mode changes from a PyLink client/server."""
|
"""Sends mode changes from a PyLink client/server."""
|
||||||
@ -150,7 +150,7 @@ class TS6Protocol(TS6BaseProtocol):
|
|||||||
(not self.irc.isInternalServer(numeric)):
|
(not self.irc.isInternalServer(numeric)):
|
||||||
raise LookupError('No such PyLink client/server exists.')
|
raise LookupError('No such PyLink client/server exists.')
|
||||||
|
|
||||||
utils.applyModes(self.irc, target, modes)
|
self.irc.applyModes(target, modes)
|
||||||
modes = list(modes)
|
modes = list(modes)
|
||||||
|
|
||||||
if utils.isChannel(target):
|
if utils.isChannel(target):
|
||||||
@ -427,8 +427,8 @@ class TS6Protocol(TS6BaseProtocol):
|
|||||||
self.updateTS(channel, their_ts)
|
self.updateTS(channel, their_ts)
|
||||||
|
|
||||||
modestring = args[2:-1] or args[2]
|
modestring = args[2:-1] or args[2]
|
||||||
parsedmodes = utils.parseModes(self.irc, channel, modestring)
|
parsedmodes = self.irc.parseModes(channel, modestring)
|
||||||
utils.applyModes(self.irc, channel, parsedmodes)
|
self.irc.applyModes(channel, parsedmodes)
|
||||||
namelist = []
|
namelist = []
|
||||||
log.debug('(%s) handle_sjoin: got userlist %r for %r', self.irc.name, userlist, channel)
|
log.debug('(%s) handle_sjoin: got userlist %r for %r', self.irc.name, userlist, channel)
|
||||||
for userpair in userlist:
|
for userpair in userlist:
|
||||||
@ -455,7 +455,7 @@ class TS6Protocol(TS6BaseProtocol):
|
|||||||
namelist.append(user)
|
namelist.append(user)
|
||||||
self.irc.users[user].channels.add(channel)
|
self.irc.users[user].channels.add(channel)
|
||||||
if their_ts <= our_ts:
|
if their_ts <= our_ts:
|
||||||
utils.applyModes(self.irc, channel, [('+%s' % mode, user) for mode in finalprefix])
|
self.irc.applyModes(channel, [('+%s' % mode, user) for mode in finalprefix])
|
||||||
self.irc.channels[channel].users.add(user)
|
self.irc.channels[channel].users.add(user)
|
||||||
return {'channel': channel, 'users': namelist, 'modes': parsedmodes, 'ts': their_ts}
|
return {'channel': channel, 'users': namelist, 'modes': parsedmodes, 'ts': their_ts}
|
||||||
|
|
||||||
@ -502,9 +502,9 @@ class TS6Protocol(TS6BaseProtocol):
|
|||||||
|
|
||||||
self.irc.users[uid] = IrcUser(nick, ts, uid, ident, host, realname, realhost, ip)
|
self.irc.users[uid] = IrcUser(nick, ts, uid, ident, host, realname, realhost, ip)
|
||||||
|
|
||||||
parsedmodes = utils.parseModes(self.irc, uid, [modes])
|
parsedmodes = self.irc.parseModes(uid, [modes])
|
||||||
log.debug('Applying modes %s for %s', parsedmodes, uid)
|
log.debug('Applying modes %s for %s', parsedmodes, uid)
|
||||||
utils.applyModes(self.irc, uid, parsedmodes)
|
self.irc.applyModes(uid, parsedmodes)
|
||||||
self.irc.servers[numeric].users.add(uid)
|
self.irc.servers[numeric].users.add(uid)
|
||||||
|
|
||||||
# Call the OPERED UP hook if +o is being added to the mode list.
|
# Call the OPERED UP hook if +o is being added to the mode list.
|
||||||
@ -563,8 +563,8 @@ class TS6Protocol(TS6BaseProtocol):
|
|||||||
channel = utils.toLower(self.irc, args[1])
|
channel = utils.toLower(self.irc, args[1])
|
||||||
oldobj = self.irc.channels[channel].deepcopy()
|
oldobj = self.irc.channels[channel].deepcopy()
|
||||||
modes = args[2:]
|
modes = args[2:]
|
||||||
changedmodes = utils.parseModes(self.irc, channel, modes)
|
changedmodes = self.irc.parseModes(channel, modes)
|
||||||
utils.applyModes(self.irc, channel, changedmodes)
|
self.irc.applyModes(channel, changedmodes)
|
||||||
ts = int(args[0])
|
ts = int(args[0])
|
||||||
return {'target': channel, 'modes': changedmodes, 'ts': ts,
|
return {'target': channel, 'modes': changedmodes, 'ts': ts,
|
||||||
'oldchan': oldobj}
|
'oldchan': oldobj}
|
||||||
@ -574,8 +574,8 @@ class TS6Protocol(TS6BaseProtocol):
|
|||||||
# <- :70MAAAAAA MODE 70MAAAAAA -i+xc
|
# <- :70MAAAAAA MODE 70MAAAAAA -i+xc
|
||||||
target = args[0]
|
target = args[0]
|
||||||
modestrings = args[1:]
|
modestrings = args[1:]
|
||||||
changedmodes = utils.parseModes(self.irc, target, modestrings)
|
changedmodes = self.irc.parseModes(target, modestrings)
|
||||||
utils.applyModes(self.irc, target, changedmodes)
|
self.irc.applyModes(target, changedmodes)
|
||||||
# Call the OPERED UP hook if +o is being set.
|
# Call the OPERED UP hook if +o is being set.
|
||||||
if ('+o', None) in changedmodes:
|
if ('+o', None) in changedmodes:
|
||||||
otype = 'Server Administrator' if ('a', None) in self.irc.users[target].modes else 'IRC Operator'
|
otype = 'Server Administrator' if ('a', None) in self.irc.users[target].modes else 'IRC Operator'
|
||||||
@ -621,7 +621,7 @@ class TS6Protocol(TS6BaseProtocol):
|
|||||||
modes = []
|
modes = []
|
||||||
for ban in args[-1].split():
|
for ban in args[-1].split():
|
||||||
modes.append(('+%s' % mode, ban))
|
modes.append(('+%s' % mode, ban))
|
||||||
utils.applyModes(self.irc, channel, modes)
|
self.irc.applyModes(channel, modes)
|
||||||
return {'target': channel, 'modes': modes, 'ts': ts}
|
return {'target': channel, 'modes': modes, 'ts': ts}
|
||||||
|
|
||||||
def handle_whois(self, numeric, command, args):
|
def handle_whois(self, numeric, command, args):
|
||||||
|
@ -83,7 +83,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
raw_modes = utils.joinModes(modes)
|
raw_modes = utils.joinModes(modes)
|
||||||
u = self.irc.users[uid] = IrcUser(nick, ts, uid, ident=ident, host=host, realname=realname,
|
u = self.irc.users[uid] = IrcUser(nick, ts, uid, ident=ident, host=host, realname=realname,
|
||||||
realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype)
|
realhost=realhost, ip=ip, manipulatable=manipulatable, opertype=opertype)
|
||||||
utils.applyModes(self.irc, uid, modes)
|
self.irc.applyModes(uid, modes)
|
||||||
self.irc.servers[server].users.add(uid)
|
self.irc.servers[server].users.add(uid)
|
||||||
|
|
||||||
# UnrealIRCd requires encoding the IP by first packing it into a binary format,
|
# UnrealIRCd requires encoding the IP by first packing it into a binary format,
|
||||||
@ -180,7 +180,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
self.irc.channels[channel].users.update(uids)
|
self.irc.channels[channel].users.update(uids)
|
||||||
if ts <= orig_ts:
|
if ts <= orig_ts:
|
||||||
# Only save our prefix modes in the channel state if our TS is lower than or equal to theirs.
|
# Only save our prefix modes in the channel state if our TS is lower than or equal to theirs.
|
||||||
utils.applyModes(self.irc, channel, changedmodes)
|
self.irc.applyModes(channel, changedmodes)
|
||||||
|
|
||||||
def ping(self, source=None, target=None):
|
def ping(self, source=None, target=None):
|
||||||
"""Sends a PING to a target server. Periodic PINGs are sent to our uplink
|
"""Sends a PING to a target server. Periodic PINGs are sent to our uplink
|
||||||
@ -215,7 +215,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
(not self.irc.isInternalServer(numeric)):
|
(not self.irc.isInternalServer(numeric)):
|
||||||
raise LookupError('No such PyLink client/server exists.')
|
raise LookupError('No such PyLink client/server exists.')
|
||||||
|
|
||||||
utils.applyModes(self.irc, target, modes)
|
self.irc.applyModes(target, modes)
|
||||||
joinedmodes = utils.joinModes(modes)
|
joinedmodes = utils.joinModes(modes)
|
||||||
if utils.isChannel(target):
|
if utils.isChannel(target):
|
||||||
# The MODE command is used for channel mode changes only
|
# The MODE command is used for channel mode changes only
|
||||||
@ -378,8 +378,8 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
self.irc.servers[numeric].users.add(uid)
|
self.irc.servers[numeric].users.add(uid)
|
||||||
|
|
||||||
# Handle user modes
|
# Handle user modes
|
||||||
parsedmodes = utils.parseModes(self.irc, uid, [modestring])
|
parsedmodes = self.irc.parseModes(uid, [modestring])
|
||||||
utils.applyModes(self.irc, uid, parsedmodes)
|
self.irc.applyModes(uid, parsedmodes)
|
||||||
|
|
||||||
# The cloaked (+x) host is completely separate from the displayed host
|
# The cloaked (+x) host is completely separate from the displayed host
|
||||||
# and real host in that it is ONLY shown if the user is +x (cloak mode
|
# and real host in that it is ONLY shown if the user is +x (cloak mode
|
||||||
@ -574,7 +574,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
self.irc.users[user].channels.add(channel)
|
self.irc.users[user].channels.add(channel)
|
||||||
# Only merge the remote's prefix modes if their TS is smaller or equal to ours.
|
# Only merge the remote's prefix modes if their TS is smaller or equal to ours.
|
||||||
if their_ts <= our_ts:
|
if their_ts <= our_ts:
|
||||||
utils.applyModes(self.irc, channel, [('+%s' % mode, user) for mode in finalprefix])
|
self.irc.applyModes(channel, [('+%s' % mode, user) for mode in finalprefix])
|
||||||
self.irc.channels[channel].users.add(user)
|
self.irc.channels[channel].users.add(user)
|
||||||
return {'channel': channel, 'users': namelist, 'modes': self.irc.channels[channel].modes, 'ts': their_ts}
|
return {'channel': channel, 'users': namelist, 'modes': self.irc.channels[channel].modes, 'ts': their_ts}
|
||||||
|
|
||||||
@ -636,9 +636,9 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
channel = utils.toLower(self.irc, args[0])
|
channel = utils.toLower(self.irc, args[0])
|
||||||
oldobj = self.irc.channels[channel].deepcopy()
|
oldobj = self.irc.channels[channel].deepcopy()
|
||||||
modes = list(filter(None, args[1:])) # normalize whitespace
|
modes = list(filter(None, args[1:])) # normalize whitespace
|
||||||
parsedmodes = utils.parseModes(self.irc, channel, modes)
|
parsedmodes = self.irc.parseModes(channel, modes)
|
||||||
if parsedmodes:
|
if parsedmodes:
|
||||||
utils.applyModes(self.irc, channel, parsedmodes)
|
self.irc.applyModes(channel, parsedmodes)
|
||||||
if numeric in self.irc.servers and args[-1].isdigit():
|
if numeric in self.irc.servers and args[-1].isdigit():
|
||||||
# Sender is a server AND last arg is number. Perform TS updates.
|
# Sender is a server AND last arg is number. Perform TS updates.
|
||||||
their_ts = int(args[-1])
|
their_ts = int(args[-1])
|
||||||
@ -690,8 +690,8 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
target = self._getUid(args[0])
|
target = self._getUid(args[0])
|
||||||
modes = args[1:]
|
modes = args[1:]
|
||||||
|
|
||||||
parsedmodes = utils.parseModes(self.irc, target, modes)
|
parsedmodes = self.irc.parseModes(target, modes)
|
||||||
utils.applyModes(self.irc, target, parsedmodes)
|
self.irc.applyModes(target, parsedmodes)
|
||||||
|
|
||||||
# If +x/-x is being set, update cloaked host info.
|
# If +x/-x is being set, update cloaked host info.
|
||||||
self.checkCloakChange(target, parsedmodes)
|
self.checkCloakChange(target, parsedmodes)
|
||||||
@ -732,8 +732,8 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
def handle_umode2(self, numeric, command, args):
|
def handle_umode2(self, numeric, command, args):
|
||||||
"""Handles UMODE2, used to set user modes on oneself."""
|
"""Handles UMODE2, used to set user modes on oneself."""
|
||||||
# <- :GL UMODE2 +W
|
# <- :GL UMODE2 +W
|
||||||
parsedmodes = utils.parseModes(self.irc, numeric, args)
|
parsedmodes = self.irc.parseModes(numeric, args)
|
||||||
utils.applyModes(self.irc, numeric, parsedmodes)
|
self.irc.applyModes(numeric, parsedmodes)
|
||||||
|
|
||||||
if ('+o', None) in parsedmodes:
|
if ('+o', None) in parsedmodes:
|
||||||
# If +o being set, call the CLIENT_OPERED internal hook.
|
# If +o being set, call the CLIENT_OPERED internal hook.
|
||||||
@ -784,7 +784,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
|
|
||||||
# When SETHOST or CHGHOST is used, modes +xt are implicitly set on the
|
# When SETHOST or CHGHOST is used, modes +xt are implicitly set on the
|
||||||
# target.
|
# target.
|
||||||
utils.applyModes(self.irc, numeric, [('+x', None), ('+t', None)])
|
self.irc.applyModes(numeric, [('+x', None), ('+t', None)])
|
||||||
|
|
||||||
return {'target': numeric, 'newhost': newhost}
|
return {'target': numeric, 'newhost': newhost}
|
||||||
|
|
||||||
@ -809,7 +809,7 @@ class UnrealProtocol(TS6BaseProtocol):
|
|||||||
|
|
||||||
# When SETHOST or CHGHOST is used, modes +xt are implicitly set on the
|
# When SETHOST or CHGHOST is used, modes +xt are implicitly set on the
|
||||||
# target.
|
# target.
|
||||||
utils.applyModes(self.irc, target, [('+x', None), ('+t', None)])
|
self.irc.applyModes(target, [('+x', None), ('+t', None)])
|
||||||
|
|
||||||
return {'target': target, 'newhost': newhost}
|
return {'target': target, 'newhost': newhost}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user