def think(self, thought):
        self.svars['stimulus'] = thought
        postdata = web.urlencode(self.svars)
        postdata += '&icognocheck=' + md5(postdata[9:29]).hexdigest()
        response = web.post('http://www.cleverbot.com/webservicemin', postdata).read().split('\r')

        self.svars['sessionid'] = response[1]
        self.svars['logurl'] = response[2]
        self.svars['vText8'] = response[3]
        self.svars['vText7'] = response[4]
        self.svars['vText6'] = response[5]
        self.svars['vText5'] = response[6]
        self.svars['vText4'] = response[7]
        self.svars['vText3'] = response[8]
        self.svars['vText2'] = response[9]
        self.svars['prevref'] = response[10]
        self.svars['emotionalhistory'] = response[12]
        self.svars['ttsLocMP3'] = response[13]
        self.svars['ttsLocTXT'] = response[14]
        self.svars['ttsLocTXT3'] = response[15]
        self.svars['ttsText'] = response[16]
        self.svars['lineRef'] = response[17]
        self.svars['lineURL'] = response[18]
        self.svars['linePOST'] = response[19]
        self.svars['lineChoices'] = response[20]
        self.svars['lineChoicesAbbrev'] = response[21]
        self.svars['typingData'] = response[22]
        self.svars['divert'] = response[23]

        return self.svars['ttsText']
Exemple #2
0
def weather(willie, trigger):
    """.weather location - Show the weather at the given location."""

    location = trigger.group(2)
    woeid = ''
    if not location:
        if willie.db and trigger.nick in willie.db.preferences:
            woeid = willie.db.preferences.get(trigger.nick, 'woeid')
        if not woeid:
            return willie.msg(
                trigger.sender, "I don't know where you live. " +
                'Give me a location, like .weather London, or tell me where you live by saying .setlocation London, for example.'
            )
    else:
        if willie.db and location in willie.db.preferences:
            woeid = willie.db.preferences.get(location, 'woeid')
        else:
            woeid = woeid_search(location).find('woeid').text

    if not woeid:
        return willie.reply("I don't know where that is.")

    query = web.urlencode({'w': woeid, 'u': 'c'})
    url = 'http://weather.yahooapis.com/forecastrss?' + query
    parsed = feedparser.parse(url)
    location = parsed['feed']['title'].encode('utf-8')

    cover = get_cover(parsed)
    temp = get_temp(parsed)
    pressure = get_pressure(parsed)
    wind = get_wind(parsed)
    willie.say(u'%s: %s, %s, %s, %s'.encode('utf-8') %
               (location, cover, temp, pressure, wind))
Exemple #3
0
def weather(bot, trigger):
    """.weather location - Show the weather at the given location."""

    location = trigger.group(2)
    woeid = ''
    if not location:
        woeid = bot.db.get_nick_value(trigger.nick, 'woeid')
        if not woeid:
            return bot.msg(
                trigger.sender, "I don't know where you live. " +
                'Give me a location, like .weather London, or tell me where you live by saying .setlocation London, for example.'
            )
    else:
        location = location.strip()
        woeid = bot.db.get_channel_value(location, 'woeid')
        if woeid is None:
            first_result = woeid_search(location)
            if first_result is not None:
                woeid = first_result.find('woeid').text

    if not woeid:
        return bot.reply("I don't know where that is.")

    query = web.urlencode({'w': woeid, 'u': 'c'})
    url = 'http://weather.yahooapis.com/forecastrss?' + query
    parsed = feedparser.parse(url)
    location = parsed['feed']['title']

    cover = get_cover(parsed)
    temp = get_temp(parsed)
    humidity = get_humidity(parsed)
    wind = get_wind(parsed)
    bot.say(u'%s: %s, %s, %s, %s' % (location, cover, temp, humidity, wind))
Exemple #4
0
def weather(bot, trigger):
    """.weather location - Show the weather at the given location."""

    location = trigger.group(2)
    woeid = ''
    if not location:
        if bot.db and trigger.nick in bot.db.preferences:
            woeid = bot.db.preferences.get(trigger.nick, 'woeid')
        if not woeid:
            return bot.msg(trigger.sender, "I don't know where you live. " +
                           'Give me a location, like .weather London, or tell me where you live by saying .setlocation London, for example.')
    else:
        location = location.strip()
        if bot.db and location in bot.db.preferences:
            woeid = bot.db.preferences.get(location, 'woeid')
        else:
            first_result = woeid_search(location)
            if first_result is not None:
                woeid = first_result.find('woeid').text

    if not woeid:
        return bot.reply("I don't know where that is.")

    query = web.urlencode({'w': woeid, 'u': 'c'})
    url = 'http://weather.yahooapis.com/forecastrss?' + query
    parsed = feedparser.parse(url)
    location = parsed['feed']['title']

    cover = get_cover(parsed)
    temp = get_temp(parsed)
    pressure = get_pressure(parsed)
    wind = get_wind(parsed)
    bot.say(u'%s: %s, %s, %s, %s' % (location, cover, temp, pressure, wind))
Exemple #5
0
def weather(bot, trigger):
    """.tempo location - Show the weather at the given location."""

    location = trigger.group(2)
    woeid = ''
    if not location:
        if bot.db and trigger.nick in bot.db.preferences:
            woeid = bot.db.preferences.get(trigger.nick, 'woeid')
        if not woeid:
            return bot.msg(trigger.sender, "Non so dove vivi. " +
                           'Dammi un comando, tipo .tempo Rome, o dimmi dove vivi con .setlocation Rome, ad esempio.')
    else:
        location = location.strip()
        if bot.db and location in bot.db.preferences:
            woeid = bot.db.preferences.get(location, 'woeid')
        else:
            first_result = woeid_search(location)
            if first_result is not None:
                woeid = first_result.find('woeid').text

    if not woeid:
        return bot.reply("Non so dove sia questo posto")

    query = web.urlencode({'w': woeid, 'u': 'c'})
    url = 'http://weather.yahooapis.com/forecastrss?' + query
    parsed = feedparser.parse(url)
    location = parsed['feed']['title']

    cover = get_cover(parsed)
    temp = get_temp(parsed)
    pressure = get_pressure(parsed)
    wind = get_wind(parsed)
    bot.say(u'%s: %s, %s, %s, %s' % (location, cover, temp, pressure, wind))
Exemple #6
0
def shindan(bot, trigger):
    """
    .shindan <id> [name] - Do the shindanmaker thing! Will automatically translate japanese shindans to english. (Waifu id: 215100 | Teh_Colt's Drama Gen id: 490953)
    """
    if not trigger.group(3) or not trigger.group(3).isdigit() or int(trigger.group(3).strip()) < 2000:
        bot.say('You must specify a shindanmaker ID (Waifu id: 215100 | Teh_Colt\'s Drama Gen id: 490953)')
        return
    
    name = trigger.nick    
    if (trigger.group(4)):
        name = trigger.group(4)
    data = web.urlencode({'u': name, 'from': ''}).encode('ascii')
    url = follow_redirects('http://en.shindanmaker.com/'+trigger.group(3).strip())
    try:
        soup = get_soup(web.post(url, data))
        shindan = soup.find(attrs={'class':re.compile("result")})
        if 'en' in url:
            bot.say(shindan.text.strip())
        else:
            msg, in_lang = translate.translate(shindan.text.strip())
            if in_lang == 'ja':
                in_lang = 'Japanese'
            bot.say('%s (Translated from %s)' % (msg, in_lang))
    except Exception as e:
        bot.say('418 I\'m a teapot')
Exemple #7
0
def shindan(bot, trigger):
    """
    .shindan <id> [name] - Do the shindanmaker thing! Will automatically translate japanese shindans to english. (Waifu id: 215100 | Teh_Colt's Drama Gen id: 490953)
    """
    if not trigger.group(3) or not trigger.group(3).isdigit() or int(
            trigger.group(3).strip()) < 2000:
        return bot.say(
            u'You must specify a shindanmaker ID (Waifu id: 215100 | T\u0081eh_Colt\'s Drama Gen id: 490953)'
        )

    name = trigger.nick
    if (trigger.group(4)):
        name = trigger.group(4)
    data = web.urlencode({'u': name, 'from': ''}).encode('ascii')
    url = follow_redirects('http://en.shindanmaker.com/' +
                           trigger.group(3).strip())
    try:
        soup = get_soup(web.post(url, data))
        shindan = soup.find(class_='result')
        if shindan is None:
            bot.say('The shindanmaker ID %s does not exist!' %
                    (trigger.group(3).strip(), ))
        else:
            bot.say(shindan.text.strip())
    except Exception as e:
        bot.say('418 I\'m a teapot')
Exemple #8
0
def old_wea(woeid):
    query = web.urlencode({'w': woeid, 'u': 'c'})
    url = 'http://weather.yahooapis.com/forecastrss?' + query
    parsed = feedparser.parse(url)
    location = parsed['feed']['title']

    cover = get_cover(parsed)
    temp = get_temp(parsed)
    pressure = get_pressure(parsed)
    wind = get_wind(parsed)
    bot.say(u'%s: %s, %s, %s, %s' % (location, cover, temp, pressure, wind))
Exemple #9
0
def woeid_search(query):
    """
    Find the first Where On Earth ID for the given query. Result is the etree
    node for the result, so that location data can still be retrieved. Returns
    None if there is no result, or the woeid field is empty.
    """
    query = web.urlencode({'q': 'select * from geo.placefinder where text="%s"' % query})
    body = web.get('http://query.yahooapis.com/v1/public/yql?' + query)
    parsed = etree.fromstring(body)
    first_result = parsed.find('results/Result')
    if first_result is None or len(first_result) == 0:
        return None
    return first_result
Exemple #10
0
def woeid_search(query):
    """
    Find the first Where On Earth ID for the given query. Result is the etree
    node for the result, so that location data can still be retrieved. Returns
    None if there is no result, or the woeid field is empty.
    """
    query = web.urlencode({'q': 'select * from geo.placefinder where text="%s"' % query})
    body = web.get('http://query.yahooapis.com/v1/public/yql?' + query)
    parsed = etree.fromstring(body)
    first_result = parsed.find('results/Result')
    if first_result is None or len(first_result) == 0:
        return None
    return first_result
Exemple #11
0
def weather(bot, trigger):
    """.weather location - Show the weather at the given location."""

    location = trigger.group(2)
    woeid = ''
    if not location:
        woeid = bot.db.get_nick_value(trigger.nick, 'woeid')
        if not woeid:
            err_str = "I don't know where you live. Give me a location, like {0}weather " \
                      "London, or tell me where you live by saying {0}setlocation London, for example.".format(
                bot.config.core.prefix
            )

            return bot.msg(trigger.sender, render_error(err_str, "weather"))
    else:
        location = location.strip()
        woeid = bot.db.get_nick_value(location, 'woeid')
        if woeid is None:
            first_result = woeid_search(location)
            if first_result is not None:
                woeid = first_result.find('woeid').text

    if not woeid:
        return bot.reply(render_error("I don't know where that is", "weather"))

    query = web.urlencode({'w': woeid, 'u': 'c'})
    url = 'http://weather.yahooapis.com/forecastrss?' + query
    parsed = feedparser.parse(url)
    location = parsed['feed']['title'][17:]

    cover = get_cover(parsed)
    temp = get_temp(parsed)
    humidity = get_humidity(parsed)
    wind = get_wind(parsed)
    bot.say(render(items=[
        EntityGroup([Entity("Weather")]),
        EntityGroup([
            Entity(location),
            Entity("Cover", cover),
            Entity("Temp", temp),
            Entity("Hum.", humidity),
            Entity("Wind", wind)
        ])
    ]))
def shindan(bot, trigger):
    """
    .shindan <id> [name] - Do the shindanmaker thing! Will automatically translate japanese shindans to english. (Waifu id: 215100 | Teh_Colt's Drama Gen id: 490953)
    """
    if not trigger.group(3) or not trigger.group(3).isdigit() or int(trigger.group(3).strip()) < 2000:
        return bot.say(u'You must specify a shindanmaker ID (Waifu id: 215100 | T\u0081eh_Colt\'s Drama Gen id: 490953)')

    name = trigger.nick
    if (trigger.group(4)):
        name = trigger.group(4)
    data = web.urlencode({'u': name, 'from': ''}).encode('ascii')
    url = follow_redirects('http://en.shindanmaker.com/' + trigger.group(3).strip())
    try:
        soup = get_soup(web.post(url, data))
        shindan = soup.find(class_='result')
        if shindan is None:
            bot.say('The shindanmaker ID %s does not exist!' % (trigger.group(3).strip(), ))
        else:
            bot.say(shindan.text.strip())
    except Exception as e:
        bot.say('418 I\'m a teapot')
Exemple #13
0
def latex(bot, trigger):
    #Request Body
    # formula=<FORMULA>&fsize=17px&fcolor=000000&mode=0&out=1&remhost=quicklatex.com&preamble=\usepackage{amsmath}\usepackage{amsfonts}\usepackage{amssymb}
    data = web.urlencode({
        'formula':
        trigger.group(2),
        'fsize':
        '25px',
        'fcolor':
        '000000',
        'mode':
        '0',
        'out':
        '1',
        'remhost':
        'quicklatex.com',
        'preamble':
        '\\usepackage{amsmath}\\usepackage{amsfonts}\\usepackage{amssymb}'
    }).encode('ascii')
    url = web.post('http://quicklatex.com/latex3.f', data).split()[1]
    bot.reply(web.get('http://is.gd/create.php?format=simple&url=' + url))
Exemple #14
0
def weather(bot, trigger):
    """.weather location - Show the weather at the given location."""

    location = trigger.group(2)
    woeid = ''
    if not location:
        if bot.db and trigger.nick in bot.db.preferences:
            woeid = bot.db.preferences.get(trigger.nick, 'woeid')
        if not woeid:
            return bot.msg(trigger.sender, "I don't know where you live. " +
                           'Give me a location, like .weather London, or tell me where you live by saying .setlocation London, for example.')
    else:
        location = location.strip()
        if bot.db and location in bot.db.preferences:
            woeid = bot.db.preferences.get(location, 'woeid')
        else:
            first_result = woeid_search(location)
            if first_result is not None:
                woeid = first_result.find('woeid').text

    if not woeid:
        return bot.reply("I don't know where that is.")

    query = web.urlencode({'w': woeid, 'u': 'c'})
    url = 'http://weather.yahooapis.com/forecastrss?' + query
    parsed = feedparser.parse(url)
    location = parsed['feed']['title']

    cover = get_cover(parsed)
    temp = get_temp(parsed)
    pressure = get_pressure(parsed)
    wind = get_wind(parsed)
    sunrise = get_sunrise(parsed)
    sunset = get_sunset(parsed)
    humidity = get_humidity(parsed)
    visibility = get_visibility(parsed)

    bot.say(u'[WEATHER] %s - %s, \x02%s\x02, %s, \x02%s\x02, ilmankosteus: \x02%s\x02, näkyvyys: \x02%s\x02, aurinko nousee \x02%s\x02 ja laskee \x02%s\x02' % (location[17:], cover, temp, wind, pressure, humidity, visibility, sunrise, sunset))
def latex(bot, trigger):
    #Request Body
    # formula=<FORMULA>&fsize=17px&fcolor=000000&mode=0&out=1&remhost=quicklatex.com&preamble=\usepackage{amsmath}\usepackage{amsfonts}\usepackage{amssymb}
    data = web.urlencode({'formula': trigger.group(2), 'fsize': '25px', 'fcolor': '000000', 'mode': '0', 'out': '1', 'remhost': 'quicklatex.com', 'preamble': '\\usepackage{amsmath}\\usepackage{amsfonts}\\usepackage{amssymb}'}).encode('ascii')
    url = web.post('http://quicklatex.com/latex3.f', data).split()[1]
    bot.reply(web.get('http://is.gd/create.php?format=simple&url=' + url))