Пример #1
0
    def fw(self, irc, msg, args, text):
        """<text>

        INVALID F*****G INPUT. PLEASE ENTER A F*****G ZIP CODE, OR A F*****G
        CITY-STATE PAIR.
        """
        if text:
            try:
                w = thefuckingweather.get_weather(text)
                ### FIXME
                #if opts:
                #    for (key, val) in opts:
                #        if key == 'metric':
                #            unit = 'c'
                #        else:
                #            unit = 'f'
                #        if key == 'forecast':
                #            f = w['forecast']
                location = ircutils.mircColor(w['location'], 'white')
                f_temp = self._color(w['current']['temperature'], 'f')
                c_temp = self._color(round((5.0/9.0)*(w['current']['temperature']-32), 1), 'c')
                weather = w['current']['weather'][0]
                remark = w['current']['remark']
                comment = "{0}: {1}, {2}?! {3}! ({4})".format(location, f_temp, c_temp, weather, remark)
            except thefuckingweather.LocationError:
                comment = "I CAN'T FIND THAT SHIT!"
            except thefuckingweather.ParseError:
                comment = "I CAN'T PARSE THE F*****G WEATHER!"

        irc.reply(comment)
Пример #2
0
def tfw(components):
    loc = components['arguments'].split('!tfw ')[1]
    print '"%s"' % loc
    tfw_result = None
    try:
        tfw_result = tfw.get_weather(loc)
    except:
        return 'Could not get weather for "%s"' % loc
        
    location = tfw_result['location']
    print '"%s"' % location
    weather = tfw_result['current']
    print '"%s"' % weather
    response = '%s - %s%s F - %s (%s)' % (location, weather['temperature'], tfw.DEGREE_SYMBOL, ' '.join(weather['weather']), weather['remark'])
    print '"%s"' % response
    return response
Пример #3
0
    def weather(self, irc, msg, args, text):
        """[<text>]

       Decide between n items separated by commas.
        """
        found = text.find("-c")
        result = False
        if (found > -1):
            #irc.reply("celsius detected.")
            text = text.replace("-c", "")
            #irc.reply(text)
            result = True
        w = thefuckingweather.get_weather(text, result)
        w_tuple = (w["current"]["temperature"], 'degrees',
                   "\n".join(w["current"]["weather"]), w["current"]["remark"])
        result = """%d %s?! %s (%s)""" % w_tuple
        result = result.replace('\n', '. ')
        irc.reply(result)
Пример #4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys

import thefuckingweather

try:
    target = " ".join(sys.argv[1:])
except:
    target = ""

try:
    data = thefuckingweather.get_weather(target)
    current = data["current"]
except thefuckingweather.LocationError:
    print "I CAN'T FIND THAT SHIT"
    
    raise SystemExit

print (u"{1} ({0}° in {3}) ({2})".format(current["temperature"], " ".join(current["weather"]), current["remark"], data["location"])).encode("utf-8")