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

coreplugin: optionally respect umode +H (hideoper) (#214)

This commit is contained in:
James Lu 2016-05-20 20:48:41 -07:00
parent 3856ee435c
commit 4cfc262bfb
2 changed files with 19 additions and 9 deletions

View File

@ -111,17 +111,23 @@ def handle_whois(irc, source, command, args):
f(server, 312, source, "%s %s :%s" % (nick, irc.servers[server].name, f(server, 312, source, "%s %s :%s" % (nick, irc.servers[server].name,
irc.servers[server].desc)) irc.servers[server].desc))
# 313: sends a string denoting the target's operator privilege, # 313: sends a string denoting the target's operator privilege if applicable.
# only if they have umode +o.
if ('o', None) in user.modes: if ('o', None) in user.modes:
# Let's be gramatically correct. (If the opertype starts with a vowel, # Check hideoper status. Require that either:
# write "an Operator" instead of "a Operator") # 1) +H is not set
n = 'n' if user.opertype[0].lower() in 'aeiou' else '' # 2) +H is set, but the caller is oper
# 3) +H is set, but whois_use_hideoper is disabled in config
isHideOper = (irc.umodes.get('hideoper'), None) in user.modes
if (not isHideOper) or (isHideOper and sourceisOper) or \
(isHideOper and not irc.botdata.get('whois_use_hideoper', True)):
# Let's be gramatically correct. (If the opertype starts with a vowel,
# 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. # 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 # This is the only syntax InspIRCd supports, but for others it doesn't
# really matter since we're handling the WHOIS requests by ourselves. # really matter since we're handling the WHOIS requests by ourselves.
f(server, 313, source, "%s :is a%s %s on %s" % (nick, n, user.opertype, netname)) f(server, 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

@ -26,6 +26,10 @@ bot:
prefixes: prefixes:
games: "@" games: "@"
# Determines whether hideoper modes should be respected in WHOIS responses.
# Defaults to true if not specified.
whois_use_hideoper: true
login: login:
# PyLink administrative login - Change this, or the service will not start! # PyLink administrative login - Change this, or the service will not start!
user: admin user: admin