From 26e102f01ac0ca06bff2f9728c2698436dde7ade Mon Sep 17 00:00:00 2001 From: James Lu Date: Mon, 31 Aug 2015 14:52:56 -0700 Subject: [PATCH] Show oper types on WHOIS --- coreplugin.py | 8 +++++++- plugins/relay.py | 5 ++++- protocols/inspircd.py | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/coreplugin.py b/coreplugin.py index 7628853..0a01d9c 100644 --- a/coreplugin.py +++ b/coreplugin.py @@ -75,7 +75,13 @@ def handle_whois(irc, source, command, args): # 313: sends a string denoting the target's operator privilege, # only if they have umode +o. if ('o', None) in user.modes: - f(irc, server, 313, source, "%s :is an IRC Operator" % nick) + if hasattr(user, 'opertype'): + opertype = user.opertype.replace("_", " ") + else: + opertype = "IRC Operator" + # Let's be gramatically correct. + n = 'n' if opertype[0].lower() in 'aeiou' else '' + f(irc, server, 313, source, "%s :is a%s %s" % (nick, n, opertype)) # 379: RPL_WHOISMODES, used by UnrealIRCd and InspIRCd. # Only show this to opers! if sourceisOper: diff --git a/plugins/relay.py b/plugins/relay.py index 44493fa..2955dab 100644 --- a/plugins/relay.py +++ b/plugins/relay.py @@ -150,7 +150,7 @@ def getRemoteUser(irc, remoteirc, user, spawnIfMissing=True): host = userobj.host[:64] realname = userobj.realname modes = getSupportedUmodes(irc, remoteirc, userobj.modes) - opertype = 'IRC_Operator_(remote)' + opertype = '' if ('o', None) in userobj.modes: if hasattr(userobj, 'opertype'): # InspIRCd's special OPERTYPE command; this is mandatory @@ -165,6 +165,8 @@ def getRemoteUser(irc, remoteirc, user, spawnIfMissing=True): log.debug('(%s) relay.getRemoteUser: setting OPERTYPE of client for %r to %s', irc.name, user, userobj.opertype) opertype = userobj.opertype + '_(remote)' + else: + opertype = 'IRC_Operator_(remote)' # Set hideoper on remote opers, to prevent inflating # /lusers and various /stats hideoper_mode = remoteirc.umodes.get('hideoper') @@ -175,6 +177,7 @@ def getRemoteUser(irc, remoteirc, user, spawnIfMissing=True): modes=modes, ts=userobj.ts, opertype=opertype).uid remoteirc.users[u].remote = (irc.name, user) + remoteirc.users[u].opertype = opertype away = userobj.away if away: remoteirc.proto.awayClient(remoteirc, u, away) diff --git a/protocols/inspircd.py b/protocols/inspircd.py index 5afc805..11ff5fb 100644 --- a/protocols/inspircd.py +++ b/protocols/inspircd.py @@ -195,6 +195,7 @@ def _operUp(irc, target, opertype=None): otype = 'IRC_Operator' log.debug('(%s) Sending OPERTYPE from %s to oper them up.', irc.name, target) + userobj.opertype = otype _send(irc, target, 'OPERTYPE %s' % otype) def _sendModes(irc, numeric, target, modes, ts=None):