Example #1
0
def hookstats(text, bot, notice_doc):
    """{global|network <name>|channel <network> <channel>|hook <hook>} - Get hook usage statistics"""
    args = text.split()
    stats_type = args.pop(0).lower()

    data = get_stats(bot)

    try:
        handler, arg_count = stats_funcs[stats_type]
    except LookupError:
        notice_doc()
        return

    if len(args) < arg_count:
        notice_doc()
        return

    headers, data = handler(data, *args[:arg_count])

    if not data:
        return "No stats available."

    table = gen_markdown_table(headers, data)

    return web.paste(table, 'md', 'hastebin')
Example #2
0
def listdetailedfactoids(chan):
    """- lists all available factoids with their respective data"""
    headers = ("Command", "Output")
    data = [(FACTOID_CHAR + fact[0], fact[1])
            for fact in sorted(factoid_cache[chan].items())]
    table = gen_markdown_table(headers, data).encode('UTF-8')
    return web.paste(table, "md", "hastebin")
Example #3
0
def pluginlist(bot):
    """- List all currently loaded plugins"""
    manager = bot.plugin_manager
    plugins = [
        (plugin.title, str(Path(plugin.file_path).resolve().relative_to(bot.base_dir)))
        for plugin in manager.plugins.values()
    ]
    plugins.sort(key=itemgetter(0))
    table = gen_markdown_table(["Plugin", "Path"], plugins)
    return web.paste(table, service="hastebin")
Example #4
0
def test_gen_md_table():
    headers = ['ColumnA', 'Column B']
    data = [
        ['1', '2'],
        ['3', '4'],
    ]
    assert gen_markdown_table(headers, data) == dedent("""
    | ColumnA | Column B |
    | ------- | -------- |
    | 1       | 2        |
    | 3       | 4        |
    """).strip()
Example #5
0
def paste_facts(facts, raise_on_no_paste=False):
    headers = ("Command", "Output")
    data = [(FACTOID_CHAR + fact[0], fact[1]) for fact in sorted(facts.items())]
    tbl = gen_markdown_table(headers, data).encode('UTF-8')
    return web.paste(tbl, 'md', 'hastebin', raise_on_no_paste=raise_on_no_paste)
Example #6
0
def format_optout_list(opts):
    headers = ("Channel Pattern", "Hook Pattern", "Allowed")
    table = [(opt.channel, opt.hook, "true" if opt.allow else "false")
             for opt in opts]
    return gen_markdown_table(headers, table)
Example #7
0
def list_tell_disabled(conn, db):
    """- Returns the current list of people who are not able to recieve tells"""
    ignores = list(list_disabled(db, conn))
    md = gen_markdown_table(["Connection", "Target", "Setter", "Set At"], ignores)
    return web.paste(md, 'md', 'hastebin')