def handle_help(bot, event): """ arguments: [<cmndname or plugname>] - show help. """ if not event.args: event.reply( "documentation for jsonbot can be found at http://jsonbot.org") event.reply( 'see !list for loaded plugins and "!help plugin" for help on the plugin.' ) return t = event.args[0] logging.warn("help target is %s" % t) cmnds.reloadcheck(bot, event, t) where = cmnds.whereis(t) cmndhelp = cmnds.gethelp(t) if not cmndhelp: ex = examples.get(t) if ex: cmndhelp = ex.descr if not cmndhelp: handle_helpplug(bot, event) return try: ex = examples[t].example except KeyError: ex = None p = cmnds.perms(t) res = "permissions: %s - location: %s - examples: %s" % (", ".join(p), where, ex) event.reply('<br><b>%s command:</b> %s' % (event.rest, cmndhelp), res.split(" - "), dot="<br>")
def handle_helpplug(bot, ievent): """ arguments: <plugname> - how help on plugin/command or show basic help msg. """ try: what = ievent.args[0] except (IndexError, TypeError): ievent.reply("available plugins: ", getpluginlist()) ievent.reply("see !help <plugin> to get help on a plugin.") return cmnds.reloadcheck(bot, ievent, what) plugin = None modname = "" perms = [] for package in plugin_packages: try: modname = "%s.%s" % (package, what) try: plugin = plugs.load_mod(modname) if plugin: break except NoSuchPlugin: continue except(KeyError, ImportError): pass if not plugin: ievent.reply("no %s plugin loaded" % what) return try: phelp = plugin.__doc__ except (KeyError, AttributeError): ievent.reply('no description of %s plugin available' % what) return cmndresult = [] if phelp: perms = ievent.user.data.perms if not perms: perms = ['GUEST', ] counter = 1 for i, j in cmnds.iteritems(): if what == j.plugname: for perm in j.perms: if perm in perms: if True: try: descr = j.func.__doc__ if not descr: descr = "no description provided" try: cmndresult.append(u" <b>!%s</b> - <i>%s</i>" % (i, descr)) except KeyError: pass except AttributeError: pass counter += 1 break if cmndresult and phelp: res = [] for r in cmndresult: if bot.type in ['web', ]: res.append("%s<br>" % r) if bot.type in ['irc', ]: res.append(r.strip()) else: res.append(r) res.sort() what = what.upper() ievent.reply('<b>help on plugin %s: </b>%s' % (what,phelp.strip())) ievent.reply("commands: ", res, dot="\n") else: if perms: ievent.reply('no commands available for permissions: %s' % ", ".join(perms)) else: ievent.reply("can't find help on %s" % what)
def handle_whereis(bot, ievent): """ arguments: <cmnd> - locate a command. """ try: cmnd = ievent.args[0] except IndexError: ievent.missing('<cmnd>') return cmnds.reloadcheck(bot, ievent, cmnd) plugin = cmnds.whereis(cmnd) if plugin: ievent.reply("%s command is in: %s" % (cmnd, plugin)) else: ievent.reply("can't find " + cmnd)
def handle_help(bot, event): """ arguments: [<cmndname or plugname>] - show help. """ if not event.args: event.reply("documentation for jsonbot can be found at http://jsonbot.org") event.reply('see !list for loaded plugins and "!help plugin" for help on the plugin.') return t = event.args[0] logging.warn("help target is %s" % t) cmnds.reloadcheck(bot, event, t) where = cmnds.whereis(t) #where = bot.plugs.getmodule(t) cmndhelp = cmnds.gethelp(t) if cmndhelp: event.reply('help on %s: ' % event.rest, cmndhelp.split("\n")) elif bot.plugs.get(t): handle_helpplug(bot, event) ; return else: event.reply("can't find help on %s" % event.rest) ; return try: ex = examples[t].example except KeyError: ex = None p = cmnds.perms(t) event.reply("permissions: %s - location: %s - examples: %s" % (", ".join(p), where, ex))
def handle_help(bot, event): """ arguments: [<cmndname or plugname>] - show help. """ if not event.args: event.reply("documentation for jsonbot can be found at http://jsonbot.org") event.reply('see !list for loaded plugins and "!help plugin" for help on the plugin.') return t = event.args[0] logging.warn("help target is %s" % t) cmnds.reloadcheck(bot, event, t) where = cmnds.whereis(t) cmndhelp = cmnds.gethelp(t) if not cmndhelp: ex = examples.get(t) if ex: cmndhelp = ex.descr if not cmndhelp: handle_helpplug(bot, event) ; return try: ex = examples[t].example except KeyError: ex = None p = cmnds.perms(t) res = "permissions: %s - location: %s - examples: %s" % (", ".join(p), where, ex) event.reply('<br><b>%s command:</b> %s' % (event.rest, cmndhelp), res.split(" - "), dot="<br>")
def handle_helpplug(bot, ievent): """ arguments: <plugname> - how help on plugin/command or show basic help msg. """ try: what = ievent.args[0] except (IndexError, TypeError): ievent.reply("available plugins: ", getpluginlist()) ievent.reply("see !help <plugin> to get help on a plugin.") return ievent.untildone = True cmnds.reloadcheck(bot, ievent, what) plugin = None modname = "" perms = [] for package in plugin_packages: try: modname = "%s.%s" % (package, what) try: plugin = plugs.load_mod(modname) if plugin: break except NoSuchPlugin: continue except (KeyError, ImportError): pass if not plugin: ievent.reply("no %s plugin loaded" % what) return try: phelp = plugin.__doc__ except (KeyError, AttributeError): ievent.reply('no description of %s plugin available' % what) return cmndresult = [] if phelp: counter = 1 for i, j in cmnds.iteritems(): if what == j.plugname: try: descr = j.func.__doc__ if not descr: descr = "no description provided" try: cmndresult.append( u" <b>!%s</b> - <i>%s</i> - perms: %s" % (i, descr, j.perms)) except KeyError: pass except AttributeError: pass counter += 1 if cmndresult and phelp: res = [] for r in cmndresult: if bot.type in [ 'web', ]: res.append("%s<br>" % r) elif bot.type in [ 'irc', ]: res.append(r.strip()) else: res.append(r) res.sort() what = what.upper() ievent.reply('<br><b>plugin %s: </b><br>%s' % (what, phelp)) ievent.reply("<b>commands: </b>", res, dot="count") else: if perms: ievent.reply('no commands available for permissions: %s' % ", ".join(perms)) else: ievent.reply("can't find help on %s" % what) ievent.done(silent=True)
def wouldmatchre(self): cmnds.reloadcheck(self.bot, self) return cmnds.wouldmatchre(self.bot, self)
def woulddispatch(self): cmnds.reloadcheck(self.bot, self) return cmnds.woulddispatch(self.bot, self)