示例#1
0
文件: core.py 项目: Petraea/jsonbot
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>")
示例#2
0
文件: core.py 项目: NURDspace/jsonbot
def handle_perm(bot, ievent):
    """ arguments: <cmnd> - get permission of command. """
    try:cmnd = ievent.args[0]
    except IndexError:
        ievent.missing("<cmnd>")
        return
    try: perms = cmnds.perms(cmnd)
    except KeyError:
        ievent.reply("no %sw command registered")
        return
    if perms: ievent.reply("%s command needs %s permission" % (cmnd, perms))
    else: ievent.reply("can't find perm for %s" % cmnd)
示例#3
0
文件: core.py 项目: Petraea/jsonbot
def handle_perm(bot, ievent):
    """ arguments: <cmnd> - get permission of command. """
    try:
        cmnd = ievent.args[0]
    except IndexError:
        ievent.missing("<cmnd>")
        return
    try:
        perms = cmnds.perms(cmnd)
    except KeyError:
        ievent.reply("no %sw command registered")
        return
    if perms: ievent.reply("%s command needs %s permission" % (cmnd, perms))
    else: ievent.reply("can't find perm for %s" % cmnd)
示例#4
0
文件: core.py 项目: code2u/jsb
def handle_help(bot, event):
    """ arguments: [<cmndname or plugname>] - show help. """
    if not event.rest:
        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
    target = cmnds.whereis(event.rest)
    target = target or event.rest
    where = bot.plugs.getmodule(target)
    cmndhelp = cmnds.gethelp(event.rest)
    if cmndhelp: event.reply('help on %s: ' % event.rest, cmndhelp.split("\n"))
    elif where: handle_helpplug(bot, event) ; return
    else: event.reply("can't find help on %s" % event.rest) ; return
    try: event.reply("examples: %s" % examples[event.rest].example)
    except KeyError: event.reply("no examples found")
    event.reply("permissions: %s" % ", ".join(cmnds.perms(event.rest)))
    if where: event.reply("%s is in the %s plugin" % (event.rest, where))
示例#5
0
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))
示例#6
0
文件: core.py 项目: NURDspace/jsonbot
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>")