From a9d2a2c4bc298d8536e48a1e0e4b9ad8a6654989 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 18 Feb 2017 13:51:45 -0800 Subject: [PATCH] relay, handlers: rewrite oper WHOIS replies to show the target's home network --- coremods/handlers.py | 5 +---- plugins/relay.py | 20 +++++++++----------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/coremods/handlers.py b/coremods/handlers.py index f80ae0a..01224f8 100644 --- a/coremods/handlers.py +++ b/coremods/handlers.py @@ -80,10 +80,7 @@ def handle_whois(irc, source, command, args): # write "an Operator" instead of "a Operator") n = 'n' if user.opertype[0].lower() in 'aeiou' else '' - # I want to normalize the syntax: PERSON is an OPERTYPE on NETWORKNAME. - # 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)) + f(313, source, "%s :is a%s %s" % (nick, n, user.opertype)) # 379: RPL_WHOISMODES, used by UnrealIRCd and InspIRCd to show user modes. # Only show this to opers! diff --git a/plugins/relay.py b/plugins/relay.py index 67c8a92..148db63 100644 --- a/plugins/relay.py +++ b/plugins/relay.py @@ -284,20 +284,18 @@ def spawn_relay_user(irc, remoteirc, user, times_tagged=0): modes = set(get_supported_umodes(irc, remoteirc, userobj.modes)) opertype = '' 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)" - # for the relayed clone, so that it shows in whois. - # Janus does this too. :) + # Try to get the oper type, adding an "(on )" suffix similar to what + # Janus does. + if hasattr(userobj, 'opertype'): log.debug('(%s) relay.get_remote_user: setting OPERTYPE of client for %r to %s', irc.name, user, userobj.opertype) - opertype = userobj.opertype + ' (remote)' + opertype = userobj.opertype else: - opertype = 'IRC Operator (remote)' + opertype = 'IRC Operator' + + opertype += ' (on %s)' % irc.getFullNetworkName() + # Set hideoper on remote opers, to prevent inflating # /lusers and various /stats 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. """ - newtype = args['text'] + ' (remote)' + newtype = '%s (on %s)' % (args['text'], irc.getFullNetworkName()) 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)