diff -r 2266d6d73de3 -r d67cc4fbc3f1 modulecore.py --- a/modulecore.py Sun Nov 09 19:59:10 2014 +0200 +++ b/modulecore.py Mon Nov 10 02:06:06 2014 +0200 @@ -1,5 +1,6 @@ import os import re +from configfile import Config Modules = {} Commands = {} @@ -75,25 +76,25 @@ cmd = Commands[cmdname] except KeyError: return False - - if cmd['level'] == 'admin' and not bot.is_admin (kvargs['ident'], kvargs['host']): - command_error ("%s requires admin access" % cmdname) - + + if cmd['level'] == 'admin' \ + and not "%s@%s" % (kvargs['ident'], kvargs['host']) in Config.get_value ('admins', default=[]): + command_error ("you may not use %s" % cmdname) + match = re.compile (cmd['regex']).match (message) - + if match == None: # didn't match + print "regex: %s" % cmd['regex'] command_error ('invalid arguments\nusage: %s %s' % (cmd['name'], cmd['args'])) - #fi - + i = 1 args = {} for argname in cmd['argnames']: args[argname] = match.group (i) i += 1 - #done - + getattr (cmd['module'], "cmd_%s" % cmdname) (bot=bot, cmdname=cmdname, args=args, **kvargs) return True @@ -116,6 +117,8 @@ if arg == '': continue + + gotliteral = False if arg[0] == '[' and arg[-1] == ']': arg = arg[1:-1] @@ -126,20 +129,20 @@ arg = arg[1:-1] else: - raise CommandError ('badly formed argument list') - #fi + gotliteral = True if arg[-3:] == '...': gotvariadic = True arg = arg[0:-3] - #fi if gotoptional == False: regex += '\s+' else: regex += '\s*' - if gotoptional: + if gotliteral: + regex += arg + elif gotoptional: if gotvariadic: regex += r'(.*)' else: