3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 01:09:22 +01:00

Show oper types on WHOIS

This commit is contained in:
James Lu 2015-08-31 14:52:56 -07:00
parent 8d19057118
commit 26e102f01a
3 changed files with 12 additions and 2 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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):