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

relay: make clientbot modesync more configurable (#287)

This commit is contained in:
James Lu 2016-09-25 20:06:24 -07:00
parent 8dd0cb19af
commit 57b566286d
2 changed files with 24 additions and 1 deletions

View File

@ -484,6 +484,12 @@ relay:
# net2.relay, etc.) if not specified.
#server_suffix: "relay.yournet.net"
# Sets whether Clientbot mode sync will be enabled. Valid options:
# "full" - Sync bans, ban/invite exceptions, prefix modes, and all RFC1459-standard modes
# "half" - Sync only bans, ban/invite exceptions, and prefix modes
# "none" - Turns off mode sync. This is the default.
#clientbot_modesync: none
games:
# Sets the nick of the Games service, if you're using it. This defaults to "games" if not defined.
nick: Games

View File

@ -738,6 +738,9 @@ whitelisted_cmodes = {'admin', 'allowinvite', 'autoop', 'ban', 'banexception',
whitelisted_umodes = {'bot', 'hidechans', 'hideoper', 'invisible', 'oper',
'regdeaf', 'stripcolor', 'noctcp', 'wallops',
'hideidle'}
clientbot_whitelisted_cmodes = {'admin', 'ban', 'banexception',
'halfop', 'invex', 'op', 'owner', 'voice'}
modesync_options = ('none', 'half', 'full')
def getSupportedCmodes(irc, remoteirc, channel, modes):
"""
Filters a channel mode change to the modes supported by the target IRCd.
@ -746,6 +749,20 @@ def getSupportedCmodes(irc, remoteirc, channel, modes):
if not remotechan: # Not a relay channel
return []
# Handle Clientbot-specific mode whitelist settings
whitelist = whitelisted_cmodes
if remoteirc.protoname == 'clientbot' or irc.protoname == 'clientbot':
modesync = conf.conf.get('relay', {}).get('clientbot_modesync', 'none').lower()
if modesync not in modesync_options:
modesync = 'none'
log.warning('relay: Bad clientbot_modesync option %s: valid values are %s',
modesync, modesync_options)
if modesync == 'none':
return [] # Do nothing
elif modesync == 'half':
whitelist = clientbot_whitelisted_cmodes
supported_modes = []
for modepair in modes:
try:
@ -770,7 +787,7 @@ def getSupportedCmodes(irc, remoteirc, channel, modes):
if supported_char is None:
break
if name not in whitelisted_cmodes:
if name not in whitelist:
log.debug("(%s) relay.getSupportedCmodes: skipping mode (%r, %r) because "
"it isn't a whitelisted (safe) mode for relay.",
irc.name, modechar, arg)