def cmdHelp(account, params, r): """ # help % get help about commands % format: .help [cmd] % cmd is the command name without leading '.' % e.g: .help bind % leaving cmd blank prints this message this command grabs and filters functions/methods' __doc__ directly and '# <category>' will assign a category for the command, any line with a leading <percent><space> will be interpreted as help document and returned to the user. """ if len(params) == 0: params = 'help' f = command.lookForCommand( params ) if f is None: r.l("!no such command") return try: cmdAlias(account, params, r) cmdCommandCategory(account, params, r) helps = re.findall( r"% (.*)$", f.__doc__, re.MULTILINE ) map( r.l, helps ) except: r.l("!no help found")
def getCategory(cmd): """ get category of a specific command, return (raw_category_word, description) on success return (None, None) on failure """ f = lookForCommand(cmd) if f is None: return (None, None) try: category = re.findall( r"# (\S+)", f.__doc__ )[0] except: category = "other" return (category, category_description[category][1])