2010-04-06 08:36:43 +00:00
|
|
|
import re
|
|
|
|
|
2010-01-17 04:24:36 +00:00
|
|
|
from util import hook
|
|
|
|
|
|
|
|
|
|
|
|
@hook.sieve
|
2010-03-27 08:42:27 +00:00
|
|
|
def sieve_suite(bot, input, func, kind, args):
|
2010-05-11 00:02:15 +00:00
|
|
|
if input.command == 'PRIVMSG' and \
|
2014-11-15 22:46:02 +00:00
|
|
|
bot.config.get('ignorebots', True) and \
|
2010-05-10 23:59:34 +00:00
|
|
|
input.nick.lower()[-3:] == 'bot' and args.get('ignorebots', True):
|
2010-05-07 23:16:44 +00:00
|
|
|
return None
|
2010-05-10 23:59:34 +00:00
|
|
|
|
|
|
|
if kind == "command":
|
|
|
|
if input.trigger in bot.config.get('disabled_commands', []):
|
2010-05-07 23:16:44 +00:00
|
|
|
return None
|
2011-04-14 01:45:07 +00:00
|
|
|
|
2011-05-11 20:40:04 +00:00
|
|
|
ignored = bot.config.get('ignored', [])
|
2010-11-26 00:37:04 +00:00
|
|
|
if input.host in ignored or input.nick in ignored:
|
|
|
|
return None
|
2011-04-14 01:45:07 +00:00
|
|
|
|
2010-05-07 23:16:44 +00:00
|
|
|
fn = re.match(r'^plugins.(.+).py$', func._filename)
|
|
|
|
disabled = bot.config.get('disabled_plugins', [])
|
|
|
|
if fn and fn.group(1).lower() in disabled:
|
2010-01-17 04:24:36 +00:00
|
|
|
return None
|
|
|
|
|
2014-04-12 05:06:17 +00:00
|
|
|
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
|
2010-01-25 00:30:00 +00:00
|
|
|
if 'deny-except' in acl:
|
2010-02-24 16:37:45 +00:00
|
|
|
allowed_channels = map(unicode.lower, acl['deny-except'])
|
2010-01-25 00:30:00 +00:00
|
|
|
if input.chan.lower() not in allowed_channels:
|
|
|
|
return None
|
|
|
|
if 'allow-except' in acl:
|
2010-02-24 16:37:45 +00:00
|
|
|
denied_channels = map(unicode.lower, acl['allow-except'])
|
2010-01-25 00:30:00 +00:00
|
|
|
if input.chan.lower() in denied_channels:
|
|
|
|
return None
|
2014-04-12 05:06:17 +00:00
|
|
|
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
|
2014-04-24 21:15:58 +00:00
|
|
|
if 'blacklist-nicks' in acl:
|
|
|
|
if input.nick.lower() in acl['blacklist-nicks']:
|
|
|
|
return None
|
2010-03-27 08:42:27 +00:00
|
|
|
|
2014-04-30 20:16:16 +00:00
|
|
|
admins = input.conn.conf.get('admins', [])
|
|
|
|
input.admin = input.host in admins or input.nick in admins
|
2010-10-26 04:13:27 +00:00
|
|
|
|
2014-04-30 20:16:16 +00:00
|
|
|
if args.get('adminonly', False):
|
|
|
|
if not input.admin:
|
2010-10-26 04:13:27 +00:00
|
|
|
return None
|
2011-04-14 01:45:07 +00:00
|
|
|
|
2010-01-17 04:24:36 +00:00
|
|
|
return input
|