3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-01-25 19:54:25 +01:00

Store opertypes with spaces instead of underscores, and only change them back when sending OPERTYPE

Another "Janus sucks" commit - it should be always using underscores when sending OPERTYPE, but it doesn't...
This commit is contained in:
James Lu 2015-09-20 11:25:45 -07:00
parent 82d129fed2
commit f38958995c
3 changed files with 10 additions and 11 deletions

View File

@ -79,7 +79,7 @@ def handle_whois(irc, source, command, args):
# only if they have umode +o. # only if they have umode +o.
if ('o', None) in user.modes: if ('o', None) in user.modes:
if hasattr(user, 'opertype'): if hasattr(user, 'opertype'):
opertype = user.opertype.replace("_", " ") opertype = user.opertype
else: else:
opertype = "IRC Operator" opertype = "IRC Operator"
# Let's be gramatically correct. # Let's be gramatically correct.

View File

@ -194,12 +194,11 @@ def getRemoteUser(irc, remoteirc, user, spawnIfMissing=True):
# If an opertype exists for the user, add " (remote)" # If an opertype exists for the user, add " (remote)"
# for the relayed clone, so that it shows in whois. # for the relayed clone, so that it shows in whois.
# Janus does this too. :) # Janus does this too. :)
# OPERTYPE uses underscores instead of spaces, FYI.
log.debug('(%s) relay.getRemoteUser: setting OPERTYPE of client for %r to %s', log.debug('(%s) relay.getRemoteUser: setting OPERTYPE of client for %r to %s',
irc.name, user, userobj.opertype) irc.name, user, userobj.opertype)
opertype = userobj.opertype + '_(remote)' opertype = userobj.opertype + ' (remote)'
else: else:
opertype = 'IRC_Operator_(remote)' opertype = 'IRC Operator (remote)'
# Set hideoper on remote opers, to prevent inflating # Set hideoper on remote opers, to prevent inflating
# /lusers and various /stats # /lusers and various /stats
hideoper_mode = remoteirc.umodes.get('hideoper') hideoper_mode = remoteirc.umodes.get('hideoper')
@ -587,7 +586,8 @@ world.whois_handlers.append(relayWhoisHandler)
def handle_operup(irc, numeric, command, args): def handle_operup(irc, numeric, command, args):
newtype = args['text'] + '_(remote)' newtype = args['text'] + '_(remote)'
for netname, user in relayusers[(irc.name, numeric)].items(): for netname, user in relayusers[(irc.name, numeric)].items():
log.debug('(%s) relay.handle_opertype: setting OPERTYPE of %s/%s to %s', irc.name, user, netname, newtype) log.debug('(%s) relay.handle_opertype: setting OPERTYPE of %s/%s to %s',
irc.name, user, netname, newtype)
remoteirc = world.networkobjects[netname] remoteirc = world.networkobjects[netname]
remoteirc.users[user].opertype = newtype remoteirc.users[user].opertype = newtype
utils.add_hook(handle_operup, 'PYLINK_CLIENT_OPERED') utils.add_hook(handle_operup, 'PYLINK_CLIENT_OPERED')

View File

@ -54,7 +54,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
modes=raw_modes, ip=ip, realname=realname, modes=raw_modes, ip=ip, realname=realname,
realhost=realhost)) realhost=realhost))
if ('o', None) in modes or ('+o', None) in modes: if ('o', None) in modes or ('+o', None) in modes:
self._operUp(uid, opertype=opertype or 'IRC_Operator') self._operUp(uid, opertype=opertype or 'IRC Operator')
return u return u
def joinClient(self, client, channel): def joinClient(self, client, channel):
@ -143,17 +143,17 @@ class InspIRCdProtocol(TS6BaseProtocol):
and the change will be reflected here.""" and the change will be reflected here."""
userobj = self.irc.users[target] userobj = self.irc.users[target]
try: try:
otype = opertype or userobj.opertype or 'IRC_Operator' otype = opertype or userobj.opertype or 'IRC Operator'
except AttributeError: except AttributeError:
log.debug('(%s) opertype field for %s (%s) isn\'t filled yet!', log.debug('(%s) opertype field for %s (%s) isn\'t filled yet!',
self.irc.name, target, userobj.nick) self.irc.name, target, userobj.nick)
# whatever, this is non-standard anyways. # whatever, this is non-standard anyways.
otype = 'IRC_Operator' otype = 'IRC Operator'
assert otype, "Tried to send an empty OPERTYPE!" assert otype, "Tried to send an empty OPERTYPE!"
log.debug('(%s) Sending OPERTYPE from %s to oper them up.', log.debug('(%s) Sending OPERTYPE from %s to oper them up.',
self.irc.name, target) self.irc.name, target)
userobj.opertype = otype userobj.opertype = otype
self._send(target, 'OPERTYPE %s' % otype) self._send(target, 'OPERTYPE %s' % otype.replace(" ", "_"))
def _sendModes(self, numeric, target, modes, ts=None): def _sendModes(self, numeric, target, modes, ts=None):
"""Internal function to send mode changes from a PyLink client/server.""" """Internal function to send mode changes from a PyLink client/server."""
@ -163,7 +163,6 @@ class InspIRCdProtocol(TS6BaseProtocol):
if ('+o', None) in modes and not utils.isChannel(target): if ('+o', None) in modes and not utils.isChannel(target):
# https://github.com/inspself.ircd/inspself.ircd/blob/master/src/modules/m_spanningtree/opertype.cpp#L26-L28 # https://github.com/inspself.ircd/inspself.ircd/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.
# Why isn't this documented anywhere, InspIRCd?
self._operUp(target) self._operUp(target)
utils.applyModes(self.irc, target, modes) utils.applyModes(self.irc, target, modes)
joinedmodes = utils.joinModes(modes) joinedmodes = utils.joinModes(modes)
@ -547,7 +546,7 @@ class InspIRCdProtocol(TS6BaseProtocol):
# command sent for it. # command sent for it.
# <- :70MAAAAAB OPERTYPE Network_Owner # <- :70MAAAAAB OPERTYPE Network_Owner
omode = [('+o', None)] omode = [('+o', None)]
self.irc.users[numeric].opertype = opertype = args[0] self.irc.users[numeric].opertype = opertype = args[0].replace("_", " ")
utils.applyModes(self.irc, numeric, omode) utils.applyModes(self.irc, 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.