- try:
- filepath = bot.parent.cfg.get('help', 'path', default='./help/%d.txt')
- for level in range(-1, 101):
- filename = filepath % (level)
- fo = open(filename, 'w')
- lines = []
- for func in helps.itervalues():
- lines += _mkhelp(level, func)
- for line in sorted(lines):
- fo.write(str(line)+"\n")
- except Exception as e:
- return e
+ 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}
+ fo = open(filename, 'w')
+ lines = []
+ for func in helps.values():
+ if module != '' and func.module != module:
+ continue
+ lines += _mkhelp(level, func)
+ for line in sorted(lines):
+ fo.write(str(line)+"\n")
+ fo.close()