Beispiel #1
0
def addquote(bot, trigger):
    """adds quote to quotes
    .addquote (quote goes here)
    """
    if not trigger.admin: return
    text = trigger.group(2)
    if not text:
        return bot.say('No quote provided.')
    fn = open('quotes.txt', 'a')
    text = uc.encode(text)
    fn.write(text)
    fn.write('\n')
    fn.close()
    bot.reply('Quote added.')
Beispiel #2
0
def quote(s, safe='/'):  # quote('abc def') -> 'abc%20def'
#    print (s)
#    s = string.replace(s, 'ä', 'ä')
#    s = string.replace(s, 'ö', 'ö')
    s = uc.encode(s)
    s = uc.decode(s)
    safe += always_safe
    safe_map = dict()
    for i in range(256):
        c = chr(i)
        safe_map[c] = (c in safe) and c or ('%%%02X' % i)
    try:
        res = map(safe_map.__getitem__, s)
    except:
        return ''
    return ''.join(res)
Beispiel #3
0
def hs_expanded(bot, trigger):
    """ Offer extended horoscope functionality.

    Ex:
    .hs view libra (show's libra horroscope)
    .hs info libra ('show's libra info)

    """

    text = trigger.group().split()

    word = ''
    sign = ''
    result = unicode()

    if len(text) < 2:
        return

    if len(text) == 2:
        word = 'view'
        sign = text[1]
    else:
        word = text[1]
        sign = text[2]

    if len(hs.keys()) == 0:
        update_hs(bot)

    if sign.lower() in hs.keys():
        if word == 'info':
            result = ''
            #result = format_sign(sign)
        elif word == 'view':
            result = hs[sign.lower()]
        else:
            return

    if result == '':
        return

    for line in result:
        bot.say(uc.encode(line))
Beispiel #4
0
def e(m):
    entity = m.group()
    if entity.startswith("&#x"):
        cp = int(entity[3:-1], 16)
        meep = unichr(cp)
    elif entity.startswith("&#"):
        cp = int(entity[2:-1])
        meep = unichr(cp)
    else:
        entity_stripped = entity[1:-1]
        try:
            char = name2codepoint[entity_stripped]
            meep = unichr(char)
        except:
            if entity_stripped in HTML_ENTITIES:
                meep = HTML_ENTITIES[entity_stripped]
            else:
                meep = str()
    try:
        return uc.decode(meep)
    except:
        return uc.decode(uc.encode(meep))
Beispiel #5
0
def horroscope(bot, trigger):
    """ Get horroscopes."""

    result = unicode()
    text = trigger.group().split()
    try:
        if not (text[0][0] == '.' or text[0][0] == '!'):
            return
        word = text[0][1:]
    except:
        return

    if len(hs.keys()) == 0:
        update_hs(bot)

    if word.lower() in hs.keys():
        result = hs[word.lower()]

    if result == '':
        return

    for line in result:
        bot.say(uc.encode(line))