- filepath = bot.parent.cfg.get('help', 'path', default='./help/%d.txt')
- for level in range(-1, 101):
- filename = filepath % (level)
+ module = ''
+ minlevel = -1
+ maxlevel = 100
+ filepath = bot.parent.cfg.get('help', 'path', default='./help/%(@)s%(#)d.txt')
+ for arg in args:
+ if arg.startswith("@"):
+ if "." in arg[1:]:
+ raise Exception('Module option must not contain "."')
+ module = arg[1:]
+ elif arg.startswith("#") and user.glevel >= lib.ADMIN:
+ minlevel = maxlevel = int(arg[1:])
+ elif arg.startswith("+"):
+ maxlevel = int(arg[1:])
+ elif arg.startswith("-"):
+ minlevel = int(arg[1:])
+ elif arg.startswith("./"):
+ if "./" in arg[1:]:
+ raise Exception('Filename option must not contain "./" except as the first two characters')
+ else:
+ filepath = os.path.join('help', arg[2:])
+ else:
+ raise Exception('Unknown option given to GENHELP: %s' % (arg))
+ for level in range(minlevel, maxlevel+1):
+ filename = filepath % {'#': level, '+': maxlevel, '-': minlevel, '@': module}