AutoMode: Fix alternative capabilities handling.

This commit is contained in:
Valentin Lorentz 2013-12-27 15:04:50 +00:00
parent 233571e4b5
commit df375e075a
2 changed files with 14 additions and 5 deletions

View File

@ -48,6 +48,10 @@ conf.registerChannelValue(AutoMode, 'enable',
conf.registerGlobalValue(AutoMode, 'owner', conf.registerGlobalValue(AutoMode, 'owner',
registry.Boolean(True, _("""Determines whether this plugin will automode registry.Boolean(True, _("""Determines whether this plugin will automode
owners even if they don't have op/halfop/voice/whatever capability."""))) owners even if they don't have op/halfop/voice/whatever capability.""")))
conf.registerChannelValue(AutoMode, 'alternativeCapabilities',
registry.Boolean(False, _("""Determines whether the bot will
check for 'alternative capabilities' (ie. autoop, autohalfop,
autovoice) in addition to/instead of classic ones.""")))
conf.registerChannelValue(AutoMode, 'fallthrough', conf.registerChannelValue(AutoMode, 'fallthrough',
registry.Boolean(False, _("""Determines whether the bot will "fall registry.Boolean(False, _("""Determines whether the bot will "fall
through" to halfop/voicing when auto-opping is turned off but through" to halfop/voicing when auto-opping is turned off but

View File

@ -57,13 +57,18 @@ class AutoMode(callbacks.Plugin):
cap_auto = ircdb.makeChannelCapability(channel, 'auto'+type) cap_auto = ircdb.makeChannelCapability(channel, 'auto'+type)
try: try:
apply_mode = ircdb.checkCapability(msg.prefix, cap, apply_mode = ircdb.checkCapability(msg.prefix, cap,
ignoreOwner=not self.registryValue('owner')) ignoreOwner=not self.registryValue('owner'),
ignoreChannelOp=True, ignoreDefaultAllow=True)
except KeyError: except KeyError:
apply_mode = False apply_mode = False
try: if self.registryValue('alternativeCapabilities', channel):
override = ircdb.checkCapability(msg.prefix, cap_auto, try:
ignoreOwner=not self.registryValue('owner')) override = ircdb.checkCapability(msg.prefix, cap_auto,
except KeyError: ignoreOwner=not self.registryValue('owner'),
ignoreChannelOp=True, ignoreDefaultAllow=True)
except KeyError:
override = False
else:
override = False override = False
if apply_mode or override: if apply_mode or override:
if override or self.registryValue(type, channel): if override or self.registryValue(type, channel):