3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-30 14:49:28 +01:00

relay, handlers: rewrite oper WHOIS replies to show the target's home network

This commit is contained in:
James Lu 2017-02-18 13:51:45 -08:00
parent 3c98ef172e
commit a9d2a2c4bc
2 changed files with 10 additions and 15 deletions

View File

@ -80,10 +80,7 @@ def handle_whois(irc, source, command, args):
# write "an Operator" instead of "a Operator") # write "an Operator" instead of "a Operator")
n = 'n' if user.opertype[0].lower() in 'aeiou' else '' n = 'n' if user.opertype[0].lower() in 'aeiou' else ''
# I want to normalize the syntax: PERSON is an OPERTYPE on NETWORKNAME. f(313, source, "%s :is a%s %s" % (nick, n, user.opertype))
# This is the only syntax InspIRCd supports, but for others it doesn't
# really matter since we're handling the WHOIS requests by ourselves.
f(313, source, "%s :is a%s %s on %s" % (nick, n, user.opertype, netname))
# 379: RPL_WHOISMODES, used by UnrealIRCd and InspIRCd to show user modes. # 379: RPL_WHOISMODES, used by UnrealIRCd and InspIRCd to show user modes.
# Only show this to opers! # Only show this to opers!

View File

@ -284,20 +284,18 @@ def spawn_relay_user(irc, remoteirc, user, times_tagged=0):
modes = set(get_supported_umodes(irc, remoteirc, userobj.modes)) modes = set(get_supported_umodes(irc, remoteirc, userobj.modes))
opertype = '' opertype = ''
if ('o', None) in userobj.modes: if ('o', None) in userobj.modes:
if hasattr(userobj, 'opertype'):
# InspIRCd's special OPERTYPE command; this is mandatory
# and setting of umode +/-o will fail unless this
# is used instead. This also sets an oper type for
# the user, which is used in WHOIS, etc.
# If an opertype exists for the user, add " (remote)" # Try to get the oper type, adding an "(on <networkname>)" suffix similar to what
# for the relayed clone, so that it shows in whois. # Janus does.
# Janus does this too. :) if hasattr(userobj, 'opertype'):
log.debug('(%s) relay.get_remote_user: setting OPERTYPE of client for %r to %s', log.debug('(%s) relay.get_remote_user: 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
else: else:
opertype = 'IRC Operator (remote)' opertype = 'IRC Operator'
opertype += ' (on %s)' % irc.getFullNetworkName()
# 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')
@ -890,7 +888,7 @@ def handle_operup(irc, numeric, command, args):
""" """
Handles setting oper types on relay clients during oper up. Handles setting oper types on relay clients during oper up.
""" """
newtype = args['text'] + ' (remote)' newtype = '%s (on %s)' % (args['text'], irc.getFullNetworkName())
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', log.debug('(%s) relay.handle_opertype: setting OPERTYPE of %s/%s to %s',
irc.name, user, netname, newtype) irc.name, user, netname, newtype)