allow channel/server level acl whitelist/blacklisting. fixes #104

This commit is contained in:
Ryan Hitchman 2014-04-11 22:06:17 -07:00
parent efe5144969
commit 6706a369ab
1 changed files with 10 additions and 2 deletions

View File

@ -22,8 +22,10 @@ def sieve_suite(bot, input, func, kind, args):
if fn and fn.group(1).lower() in disabled:
return None
acl = bot.config.get('acls', {}).get(func.__name__)
if acl:
acls = bot.config.get('acls', {})
for acl in [acls.get(func.__name__), acls.get(input.chan), acls.get(input.conn.server)]:
if acl is None:
continue
if 'deny-except' in acl:
allowed_channels = map(unicode.lower, acl['deny-except'])
if input.chan.lower() not in allowed_channels:
@ -32,6 +34,12 @@ def sieve_suite(bot, input, func, kind, args):
denied_channels = map(unicode.lower, acl['allow-except'])
if input.chan.lower() in denied_channels:
return None
if 'whitelist' in acl:
if func.__name__ not in acl['whitelist']:
return None
if 'blacklist' in acl:
if func.__name__ in acl['whitelist']:
return None
if args.get('adminonly', False):
admins = bot.config.get('admins', [])