This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
CloudBot/plugins/sieve.py

39 lines
1.2 KiB
Python
Raw Normal View History

2011-11-20 10:23:31 +01:00
import re
from util import hook
@hook.sieve
def sieve_suite(bot, input, func, kind, args):
2012-04-02 18:17:55 +02:00
if input.command == 'PRIVMSG' and\
2012-03-29 00:23:20 +02:00
input.nick.endswith('bot') and args.get('ignorebots', True):
2011-11-20 10:23:31 +01:00
return None
if kind == "command":
if input.trigger in bot.config.get('disabled_commands', []):
return None
fn = re.match(r'^plugins.(.+).py$', func._filename)
disabled = bot.config.get('disabled_plugins', [])
if fn and fn.group(1).lower() in disabled:
return None
acl = bot.config.get('acls', {}).get(func.__name__)
if acl:
if 'deny-except' in acl:
allowed_channels = map(unicode.lower, acl['deny-except'])
if input.chan.lower() not in allowed_channels:
return None
if 'allow-except' in acl:
denied_channels = map(unicode.lower, acl['allow-except'])
if input.chan.lower() in denied_channels:
return None
if args.get('adminonly', False):
admins = bot.config.get('admins', [])
2012-04-02 19:30:58 +02:00
if input.nick.lower() not in admins and input.mask.lower() not in admins:
2012-04-02 04:01:20 +02:00
input.notice("Sorry, you are not allowed to use this command.")
2012-03-12 21:33:52 +01:00
return None
2011-11-20 10:23:31 +01:00
2012-03-29 00:23:20 +02:00
return input