mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-24 03:29:28 +01:00
New test-passing implementation of checkCapability with debug.printfs commented out.
This commit is contained in:
parent
67e072c746
commit
2456082661
35
src/ircdb.py
35
src/ircdb.py
@ -490,7 +490,9 @@ def checkIgnored(hostmask, recipient='', users=users, channels=channels):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def checkCapability(hostmask, capability, users=users, channels=channels):
|
def checkCapability(hostmask, capability, users=users, channels=channels):
|
||||||
|
#debug.printf('*** checking %s for %s' % (hostmask, capability))
|
||||||
if world.startup:
|
if world.startup:
|
||||||
|
#debug.printf('world.startup is active.')
|
||||||
if isAntiCapability(capability):
|
if isAntiCapability(capability):
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
@ -498,46 +500,73 @@ def checkCapability(hostmask, capability, users=users, channels=channels):
|
|||||||
try:
|
try:
|
||||||
u = users.getUser(hostmask)
|
u = users.getUser(hostmask)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
#debug.printf('user could not be found.')
|
||||||
if isChannelCapability(capability):
|
if isChannelCapability(capability):
|
||||||
|
#debug.printf('isChannelCapability true.')
|
||||||
(channel, capability) = fromChannelCapability(capability)
|
(channel, capability) = fromChannelCapability(capability)
|
||||||
try:
|
try:
|
||||||
c = channels.getChannel(channel)
|
c = channels.getChannel(channel)
|
||||||
if capability in c.capabilities:
|
if capability in c.capabilities:
|
||||||
|
#debug.printf('capability in c.capabilities')
|
||||||
return c.checkCapability(capability)
|
return c.checkCapability(capability)
|
||||||
|
else:
|
||||||
|
#debug.printf('capability not in c.capabilities')
|
||||||
|
if isAntiCapability(capability):
|
||||||
|
return not c.defaultAllow
|
||||||
else:
|
else:
|
||||||
return c.defaultAllow
|
return c.defaultAllow
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
#debug.printf('no such channel %s' % channel)
|
||||||
pass
|
pass
|
||||||
if capability in conf.defaultCapabilities:
|
if capability in conf.defaultCapabilities:
|
||||||
|
#debug.printf('capability in conf.defaultCapability')
|
||||||
return True
|
return True
|
||||||
elif invertCapability(capability) in conf.defaultCapabilities:
|
elif invertCapability(capability) in conf.defaultCapabilities:
|
||||||
|
#debug.printf('inverse capability in conf.defaultCapability')
|
||||||
return False
|
return False
|
||||||
|
else:
|
||||||
|
#debug.printf('returning appropriate value given no good reason')
|
||||||
|
if isAntiCapability(capability):
|
||||||
|
return not conf.defaultAllow
|
||||||
else:
|
else:
|
||||||
return conf.defaultAllow
|
return conf.defaultAllow
|
||||||
|
#debug.printf('user found.')
|
||||||
if capability in u.capabilities:
|
if capability in u.capabilities:
|
||||||
|
#debug.printf('found capability in u.capabilities.')
|
||||||
return u.checkCapability(capability)
|
return u.checkCapability(capability)
|
||||||
else:
|
else:
|
||||||
if isChannelCapability(capability):
|
if isChannelCapability(capability):
|
||||||
|
#debug.printf('isChannelCapability true, user found too.')
|
||||||
(channel, capability) = fromChannelCapability(capability)
|
(channel, capability) = fromChannelCapability(capability)
|
||||||
try:
|
try:
|
||||||
c = channels.getChannel(channel)
|
c = channels.getChannel(channel)
|
||||||
|
#debug.printf('channel found')
|
||||||
if capability in c.capabilities:
|
if capability in c.capabilities:
|
||||||
|
#debug.printf('capability in c.capabilities')
|
||||||
return c.checkCapability(capability)
|
return c.checkCapability(capability)
|
||||||
|
else:
|
||||||
|
#debug.printf('capability not in c.capabilities')
|
||||||
|
if isAntiCapability(capability):
|
||||||
|
return not c.defaultAllow
|
||||||
else:
|
else:
|
||||||
return c.defaultAllow
|
return c.defaultAllow
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
#debug.printf('no such channel %s' % channel)
|
||||||
pass
|
pass
|
||||||
if capability in conf.defaultCapabilities:
|
if capability in conf.defaultCapabilities:
|
||||||
|
#debug.printf('capability in conf.defaultCapabilities')
|
||||||
return True
|
return True
|
||||||
elif invertCapability(capability) in conf.defaultCapabilities:
|
elif invertCapability(capability) in conf.defaultCapabilities:
|
||||||
|
#debug.printf('inverse capability in conf.defaultCapabilities')
|
||||||
return False
|
return False
|
||||||
|
else:
|
||||||
|
#debug.printf('returning appropriate value given no good reason')
|
||||||
|
if isAntiCapability(capability):
|
||||||
|
return not conf.defaultAllow
|
||||||
else:
|
else:
|
||||||
return conf.defaultAllow
|
return conf.defaultAllow
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def checkCapabilities(hostmask, capabilities, requireAll=False):
|
def checkCapabilities(hostmask, capabilities, requireAll=False):
|
||||||
"""Checks that a user has capabilities in a list.
|
"""Checks that a user has capabilities in a list.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user