new config format

This commit is contained in:
Luke Rogers 2013-10-01 23:54:08 +13:00
parent 2466c9fbb4
commit 95d6570436
5 changed files with 68 additions and 68 deletions

View file

@ -20,19 +20,21 @@ def invite(paraml, conn=None):
# Identify to NickServ (or other service)
@hook.event('004')
def onjoin(paraml, conn=None, bot=None):
nickserv_password = conn.conf.get('nickserv_password', '')
nickserv_name = conn.conf.get('nickserv_name', 'nickserv')
nickserv_account_name = conn.conf.get('nickserv_user', '')
nickserv_command = conn.conf.get('nickserv_command', 'IDENTIFY')
if nickserv_password:
if nickserv_password in bot.config['censored_strings']:
bot.config['censored_strings'].remove(nickserv_password)
if nickserv_account_name:
conn.msg(nickserv_name, "{} {} {}".format(nickserv_command, nickserv_account_name, nickserv_password))
else:
conn.msg(nickserv_name, "{} {}".format(nickserv_command, nickserv_password))
bot.config['censored_strings'].append(nickserv_password)
time.sleep(1)
nickserv = conn.conf.get('nickserv')
if nickserv:
nickserv_password = nickserv.get('nickserv_password', '')
nickserv_name = nickserv.get('nickserv_name', 'nickserv')
nickserv_account_name = nickserv.get('nickserv_user', '')
nickserv_command = nickserv.get('nickserv_command', 'IDENTIFY')
if nickserv_password:
if nickserv_password in bot.config['censored_strings']:
bot.config['censored_strings'].remove(nickserv_password)
if nickserv_account_name:
conn.msg(nickserv_name, "{} {} {}".format(nickserv_command, nickserv_account_name, nickserv_password))
else:
conn.msg(nickserv_name, "{} {}".format(nickserv_command, nickserv_password))
bot.config['censored_strings'].append(nickserv_password)
time.sleep(1)
# Set bot modes
mode = conn.conf.get('mode')

View file

@ -6,20 +6,22 @@ from fnmatch import fnmatch
@hook.sieve
def sieve_suite(bot, input, func, kind, args):
conn = input.conn
if input.command == 'PRIVMSG' and \
input.nick.endswith('bot') and args.get('ignorebots', True):
return None
if kind == "command":
if input.trigger in bot.config.get('disabled_commands', []):
disabled_commands = conn.conf.get('disabled_plugins', [])
if input.trigger in disabled_commands:
return None
fn = re.match(r'^plugins.(.+).py$', func._filename)
disabled = bot.config.get('disabled_plugins', [])
disabled = conn.conf.get('disabled_plugins', [])
if fn and fn.group(1).lower() in disabled:
return None
acl = bot.config.get('acls', {}).get(func.__name__)
acl = conn.conf.get('acls', {}).get(func.__name__)
if acl:
if 'deny-except' in acl:
allowed_channels = map(unicode.lower, acl['deny-except'])
@ -35,7 +37,7 @@ def sieve_suite(bot, input, func, kind, args):
args["permissions"] = ["adminonly"]
if args.get('permissions', False):
groups = bot.config.get("permissions", [])
groups = conn.conf.get("permissions", [])
allowed_permissions = args.get('permissions', [])
allowed_groups = []
@ -57,7 +59,7 @@ def sieve_suite(bot, input, func, kind, args):
mask = input.mask.lower()
for group in allowed_groups:
group_users = bot.config.get("permissions", {}).get(group, [])["users"]
group_users = conn.conf.get("permissions", {}).get(group, [])["users"]
group_users = [_mask.lower() for _mask in group_users]
for pattern in group_users:
if fnmatch(mask, pattern):

View file

@ -3,7 +3,7 @@ from util import hook
from fnmatch import fnmatch
@hook.sieve
#@hook.sieve
def ignore_sieve(bot, input, func, type, args):
""" blocks input from ignored channels/hosts """
ignorelist = bot.config["plugins"]["ignore"]["ignored"]