Add supybot.capabilities.registeredUsers, to give default capabilities to all registered users.

This commit is contained in:
Valentin Lorentz 2018-01-05 19:24:54 +01:00
parent d656db454d
commit b9a159b68a

View File

@ -1114,8 +1114,11 @@ def checkCapability(hostmask, capability, users=users, channels=channels,
else: else:
return False return False
defaultCapabilities = conf.supybot.capabilities() defaultCapabilities = conf.supybot.capabilities()
defaultCapabilitiesRegistered = conf.supybot.capabilities.registeredUsers()
if capability in defaultCapabilities: if capability in defaultCapabilities:
return defaultCapabilities.check(capability) return defaultCapabilities.check(capability)
elif capability in defaultCapabilitiesRegistered:
return defaultCapabilitiesRegistered.check(capability)
elif ignoreDefaultAllow: elif ignoreDefaultAllow:
return _x(capability, False) return _x(capability, False)
else: else:
@ -1141,8 +1144,10 @@ def checkCapabilities(hostmask, capabilities, requireAll=False):
# supybot.capabilities # supybot.capabilities
### ###
class DefaultCapabilities(registry.SpaceSeparatedListOfStrings): class SpaceSeparatedListOfCapabilities(registry.SpaceSeparatedListOfStrings):
List = CapabilitySet List = CapabilitySet
class DefaultCapabilities(SpaceSeparatedListOfCapabilities):
# We use a keyword argument trick here to prevent eval'ing of code that # We use a keyword argument trick here to prevent eval'ing of code that
# changes allowDefaultOwner from affecting this. It's not perfect, but # changes allowDefaultOwner from affecting this. It's not perfect, but
# it's still an improvement, raising the bar for potential crackers. # it's still an improvement, raising the bar for potential crackers.
@ -1163,6 +1168,11 @@ conf.registerGlobalValue(conf.supybot, 'capabilities',
to override these capabilities. See docs/CAPABILITIES if you don't to override these capabilities. See docs/CAPABILITIES if you don't
understand why these default to what they do.""")) understand why these default to what they do."""))
conf.registerGlobalValue(conf.supybot.capabilities, 'registeredUsers',
SpaceSeparatedListOfCapabilities([], """These are the
capabilities that are given to every authenticated by default.
You probably want to use supybot.capabilities instead, to give these
capabilities both to registered and non-registered users."""))
conf.registerGlobalValue(conf.supybot.capabilities, 'default', conf.registerGlobalValue(conf.supybot.capabilities, 'default',
registry.Boolean(True, """Determines whether the bot by default will allow registry.Boolean(True, """Determines whether the bot by default will allow
users to have a capability. If this is disabled, a user must explicitly users to have a capability. If this is disabled, a user must explicitly