mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-30 14:49:28 +01:00
relay: make clientbot modesync more configurable (#287)
This commit is contained in:
parent
8dd0cb19af
commit
57b566286d
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user