Exemplo n.º 1
0
def eightball(input, me=None):
    "8ball <question> -- The all knowing magic eight ball, " \
    "in electronic form. Ask and it shall be answered!"

    # here we use voodoo magic to tell the future
    magic = multiword_replace(random.choice(responses), color_codes)
    me("shakes the magic 8 ball... %s" % magic)
Exemplo n.º 2
0
def eightball(input, me=None):
    "8ball <question> -- The all knowing magic eight ball, " \
    "in electronic form. Ask and it shall be answered!"

    # here we use voodoo magic to tell the future
    magic = multiword_replace(random.choice(responses), color_codes)
    me("shakes the magic 8 ball... %s" % magic)
Exemplo n.º 3
0
def factoid(inp, message=None, db=None, bot=None, action=None, conn=None, input=None):
    """?<word> -- Shows what data is associated with <word>."""
    try:
        prefix_on = bot.config["plugins"]["factoids"].get("prefix", False)
    except KeyError:
        prefix_on = False

    db_init(db, conn)

    # split up the input
    split = inp.group(1).strip().split(" ")
    factoid_id = split[0]

    if len(split) >= 1:
        arguments = u" ".join(split[1:])
    else:
        arguments = ""

    data = get_memory(db, factoid_id)

    if data:
        # factoid preprocessors
        if data.startswith("<py>"):
            code = data[4:].strip()
            variables = u'input="""{}"""; nick="{}"; chan="{}"; bot_nick="{}"; '.format(arguments.replace('"', '\\"'),
                                                                                       input.nick, input.chan,
                                                                                       input.conn.nick)
            if code.startswith("<force>"):
                code = code[8:].strip()
                result = unicode(pyexec.eval_py(variables + code, paste_multiline=False))
            else:
                result = unicode(pyexec.eval_py(variables + code))
        else:
            result = unicode(data)

        # factoid postprocessors
        result = text.multiword_replace(result, shortcodes)

        if result.startswith("<act>"):
            result = result[5:].strip()
            action(result)
        elif result.startswith("<url>"):
            url = result[5:].strip()
            try:
                message(http.get(url))
            except http.HttpError:
                message("Could not fetch URL.")
        else:
            if "\n" in result:
                result = result.strip("\r").split("\n")
                for output in result:
                    if prefix_on:
                        message(u"\x02[{}]:\x02 {}".format(factoid_id, output))
                    else:
                        message(output)
            else:
                if prefix_on:
                    message(u"\x02[{}]:\x02 {}".format(factoid_id, result))
                else:
                    message(result)
Exemplo n.º 4
0
def hashtag(inp, say=None, db=None, bot=None, me=None, conn=None, input=None, chan=None, notice=None):
    "<word>? -- Shows what data is associated with <word>."
    disabledhashes = database.get(db,'channels','disabledhashes','chan',chan)
    split = inp.group(1).strip().split(" ")

    try:
        if chan[0] != '#':
            pass
        elif split[0].lower() in disabledhashes.lower():
            notice('{} is disabled.'.format(split[0]))
            return
    except TypeError:
        pass

    try:
        prefix_on = bot.config["plugins"]["factoids"].get("prefix", False)
    except KeyError:
        prefix_on = False

    db_init(db)

    # split up the input
    split = inp.group(1).strip().split(" ")
    factoid_id = split[0]

    if len(split) >= 1:
        arguments = " ".join(split[1:])
    else:
        arguments = ""

    data = get_memory(db, factoid_id)

    if data:
        # factoid preprocessors
        if data.startswith("<py>"):
            code = data[4:].strip()
            variables = 'input="""%s"""; nick="%s"; chan="%s"; bot_nick="%s";' % (arguments.replace('"', '\\"'),
                        input.nick, input.chan, input.conn.nick)
            result = execute.eval_py(variables + code)
        elif data.startswith("<url>"):
            url = data[5:].strip()
            try:
                result = http.get(url)
            except http.HttpError:
                result = "Could not fetch URL."
        else:
            result = data

        # factoid postprocessors
        result = text.multiword_replace(result, shortcodes)

        if result.startswith("<act>"):
            result = result[5:].strip()
            me(result)
        else:
            if prefix_on:
                say("\x02[%s]:\x02 %s" % (factoid_id, result))
            else:
                say("\x02%s\x02 %s" % (factoid_id, result))
Exemplo n.º 5
0
def factoid(inp, say=None, db=None, bot=None, me=None, conn=None, input=None):
    "<word>? -- Shows what data is associated with <word>."
    try:
        prefix_on = bot.config["plugins"]["factoids"].get("prefix", False)
    except KeyError:
        prefix_on = False

    db_init(db)

    # split up the input
    split = inp.group(1).strip().split(" ")
    factoid_id = split[0]

    if len(split) >= 1:
        arguments = " ".join(split[1:])
    else:
        arguments = ""

    data = get_memory(db, factoid_id)

    if data:
        # factoid preprocessors
        if data.startswith("<py>"):
            code = data[4:].strip()
            variables = 'input="""%s"""; nick="%s"; chan="%s"; bot_nick="%s";' % (
                arguments.replace(
                    '"', '\\"'), input.nick, input.chan, input.conn.nick)
            result = execute.eval_py(variables + code)
        elif data.startswith("<url>"):
            url = data[5:].strip()
            try:
                result = http.get(url)
            except http.HttpError:
                result = "Could not fetch URL."
        else:
            result = data

        # factoid postprocessors
        result = text.multiword_replace(result, shortcodes)

        if result.startswith("<act>"):
            result = result[5:].strip()
            me(result)
        else:
            if prefix_on:
                say("\x02[%s]:\x02 %s" % (factoid_id, result))
            else:
                say("\x02%s\x02 %s" % (factoid_id, result))
Exemplo n.º 6
0
def factoid(inp, message=None, db=None, bot=None, action=None, conn=None, input=None):
    "?<word> -- Shows what data is associated with <word>."
    try:
        prefix_on = bot.config["plugins"]["factoids"].get("prefix", False)
    except KeyError:
        prefix_on = False

    db_init(db)

    # split up the input
    split = inp.group(1).strip().split(" ")
    factoid_id = split[0]

    if len(split) >= 1:
        arguments = " ".join(split[1:])
    else:
        arguments = ""

    data = get_memory(db, factoid_id)

    if data:
        # factoid preprocessors
        if data.startswith("<py>"):
            code = data[4:].strip()
            variables = 'input="""{}"""; nick="{}"; chan="{}"; bot_nick="{}";'.format(arguments.replace('"', '\\"'),
                                                                                  input.nick, input.chan,
                                                                                  input.conn.nick)
            result = execute.eval_py(variables + code)
        else:
            result = data

        # factoid postprocessors
        result = text.multiword_replace(result, shortcodes)

        if result.startswith("<act>"):
            result = result[5:].strip()
            action(result)
        elif result.startswith("<url>"):
            url = result[5:].strip()
            try:
                message(http.get(url))
            except http.HttpError:
                message("Could not fetch URL.")
        else:
            if prefix_on:
                message("\x02[{}]:\x02 {}".format(factoid_id, result))
            else:
                message(result)
Exemplo n.º 7
0
def factoid(inp,
            message=None,
            db=None,
            bot=None,
            action=None,
            conn=None,
            input=None):
    "?<word> -- Shows what data is associated with <word>."

    db_init(db)

    # split up the input
    split = inp.group(1).strip().split(" ")
    factoid_id = split[0]

    if len(split) >= 1:
        arguments = " ".join(split[1:])
    else:
        arguments = ""

    data = get_memory(db, factoid_id)

    if data:
        # factoid preprocessors
        if data.startswith("<py>"):
            code = data[4:].strip()
            variables = 'input="""{}"""; nick="{}"; chan="{}"; bot_nick="{}";'.format(
                arguments.replace('"', '\\"'), input.nick, input.chan,
                input.conn.nick)
            result = execute.eval_py(variables + code)
        else:
            result = data

        # factoid postprocessors
        result = text.multiword_replace(result, shortcodes)

        if result.startswith("<act>"):
            result = result[5:].strip()
            action(result)
        elif result.startswith("<url>"):
            url = result[5:].strip()
            try:
                message(http.get(url))
            except http.HttpError:
                message("Could not fetch URL.")
        else:
            message(result)
Exemplo n.º 8
0
def eightball(input, action=None):
    """8ball <question> -- The all knowing magic eight ball,
    in electronic form. Ask and it shall be answered!"""

    magic = text.multiword_replace(random.choice(responses), color_codes)
    action("shakes the magic 8 ball... {}".format(magic))
Exemplo n.º 9
0
def eightball(input, me=None):
    """8ball <question> -- The all knowing magic eight ball,
    =in electronic form. Ask and it shall be answered!"""
    magic = text.multiword_replace(random.choice(responses), color_codes)
    me("shakes the magic 8 ball... {}".format(magic))
    return
Exemplo n.º 10
0
def hashtag(inp,
            say=None,
            db=None,
            bot=None,
            me=None,
            conn=None,
            input=None,
            chan=None,
            notice=None):
    "<word>? -- Shows what data is associated with <word>."
    disabledhashes = database.get(db, 'channels', 'disabledhashes', 'chan',
                                  chan)
    split = inp.group(1).strip().split(" ")

    try:
        if chan[0] != '#':
            pass
        elif split[0].lower() in disabledhashes.lower():
            notice('{} is disabled.'.format(split[0]))
            return
    except TypeError:
        pass
    except AttributeError:
        pass

    try:
        prefix_on = bot.config["plugins"]["factoids"].get("prefix", False)
    except KeyError:
        prefix_on = False

    db_init(db)

    # split up the input
    split = inp.group(1).strip().split(" ")
    factoid_id = split[0]

    if len(split) >= 1:
        arguments = " ".join(split[1:])
    else:
        arguments = ""

    data = get_memory(db, factoid_id)

    if data:
        # factoid preprocessors
        if data.startswith("<py>"):
            # don't execute code
            result = data[4:].strip()
        elif data.startswith("<url>"):
            # don't download pages
            result = data[5:].strip()
        else:
            result = data

        # factoid postprocessors
        result = text.multiword_replace(result, shortcodes)

        if result.startswith("<act>"):
            result = result[5:].strip()
            me(result)
        else:
            if prefix_on:
                say("\x02[%s]:\x02 %s" % (factoid_id, result))
            else:
                say("\x02%s\x02 %s" % (factoid_id, result))
Exemplo n.º 11
0
def mball(input, me=None):
    "mball <question> -- The all knowing magic eight ball, " \
    "in electronic form. Ask and it shall be answered!"

    magic = text.multiword_replace(random.choice(responses), color_codes)
    me("shakes the magic 8 ball... %s" % magic)