2011-10-19 18:56:04 -04:00
|
|
|
#!/usr/bin/python3
|
2012-02-22 15:40:26 -05:00
|
|
|
# -*- coding: utf-8 -*-
|
2010-12-06 16:12:28 -05:00
|
|
|
"""
|
|
|
|
tfw.py - the fucking weather module
|
2013-11-27 01:41:48 -05:00
|
|
|
mostly remarks and flavors from thefuckingweather.com
|
|
|
|
http://thefuckingweather.com/HelpThisGuy.aspx
|
|
|
|
|
2012-01-03 14:09:34 -05:00
|
|
|
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
|
2010-12-06 16:12:28 -05:00
|
|
|
"""
|
|
|
|
|
2012-06-02 01:17:09 -04:00
|
|
|
from tools import GrumbleError
|
2013-01-10 22:08:52 -05:00
|
|
|
from modules import weather
|
|
|
|
import random
|
|
|
|
import metar
|
2011-09-21 20:43:05 -04:00
|
|
|
import web
|
2010-12-06 16:12:28 -05:00
|
|
|
|
2013-10-01 01:40:03 -04:00
|
|
|
|
2014-04-25 20:27:50 -04:00
|
|
|
def tfw(phenny, input, fahrenheit=False, celsius=False, mev=False):
|
2011-12-04 19:46:28 -05:00
|
|
|
""".tfw <city/zip> - Show the fucking weather at the specified location."""
|
2010-12-08 22:00:54 -05:00
|
|
|
|
2012-04-24 14:28:56 -04:00
|
|
|
where = input.group(2)
|
|
|
|
if not where:
|
2011-12-04 19:46:28 -05:00
|
|
|
# default to Blacksburg, VA
|
2013-01-10 22:08:52 -05:00
|
|
|
icao_code = "KBCB"
|
|
|
|
else:
|
|
|
|
icao_code = weather.code(phenny, where)
|
2010-12-06 16:12:28 -05:00
|
|
|
|
2013-10-01 01:40:03 -04:00
|
|
|
if not icao_code:
|
2017-07-28 22:57:12 -04:00
|
|
|
phenny.say("WHERE THE FUCK IS THAT? I guess you might think it's a place, but no one else does. Try again.")
|
2013-01-10 22:08:52 -05:00
|
|
|
return
|
2010-12-06 16:12:28 -05:00
|
|
|
|
2017-02-11 01:47:30 -05:00
|
|
|
uri = 'http://tgftp.nws.noaa.gov/data/observations/metar/stations/%s.TXT'
|
2011-12-04 19:43:46 -05:00
|
|
|
try:
|
2013-01-10 22:08:52 -05:00
|
|
|
bytes = web.get(uri % icao_code)
|
2013-10-01 01:40:03 -04:00
|
|
|
except AttributeError:
|
2013-01-10 22:08:52 -05:00
|
|
|
raise GrumbleError("THE INTERNET IS FUCKING BROKEN. Please try again later.")
|
2013-06-09 01:27:24 -04:00
|
|
|
except web.HTTPError:
|
2017-07-28 22:57:12 -04:00
|
|
|
phenny.say("WHERE THE FUCK IS THAT? I guess you might think it's a place, but no one else does. Try again.")
|
2013-01-10 22:08:52 -05:00
|
|
|
return
|
2012-06-05 00:42:56 -04:00
|
|
|
|
2013-10-01 01:40:03 -04:00
|
|
|
if 'Not Found' in bytes:
|
2017-07-28 22:57:12 -04:00
|
|
|
phenny.say("WHERE THE FUCK IS THAT? I guess you might think it's a place, but no one else does. Try again.")
|
2011-12-04 19:46:28 -05:00
|
|
|
return
|
2010-12-06 17:53:04 -05:00
|
|
|
|
2013-01-10 22:08:52 -05:00
|
|
|
w = metar.parse(bytes)
|
|
|
|
tempf = w.temperature * 9 / 5 + 32
|
|
|
|
|
2011-12-04 19:46:28 -05:00
|
|
|
# add units and convert if necessary
|
|
|
|
if fahrenheit:
|
2013-01-10 22:08:52 -05:00
|
|
|
temp = "{0:d}°F‽".format(int(tempf))
|
2011-12-04 19:46:28 -05:00
|
|
|
elif celsius:
|
2013-01-10 22:08:52 -05:00
|
|
|
temp = "{0:d}°C‽".format(w.temperature)
|
2014-04-25 16:30:41 -04:00
|
|
|
else:
|
2014-05-15 17:19:48 -04:00
|
|
|
tempev = (w.temperature + 273.15) * 8.6173324e-5 / 2
|
|
|
|
if mev:
|
|
|
|
temp = "{0:f} meV‽".format(tempev * 1000)
|
|
|
|
else:
|
|
|
|
temp = "{0:f} Meters‽".format(tempev * 12.39842)
|
2013-01-10 22:08:52 -05:00
|
|
|
|
|
|
|
if w.temperature < 6:
|
|
|
|
remark = "IT'S FUCKING COLD"
|
2013-10-01 01:40:03 -04:00
|
|
|
flavors = [
|
|
|
|
"Where's the cat? Oh shit. Fluffy's frozen.",
|
2013-01-10 22:08:52 -05:00
|
|
|
"Nothing a few shots couldn't fix",
|
|
|
|
"Should have gone south",
|
|
|
|
"You think this is cold? Have you been to upstate New York?",
|
2017-07-28 22:57:12 -04:00
|
|
|
"Why do I live here?",
|
|
|
|
"wang icicles.",
|
|
|
|
"Freezing my balls off out here",
|
|
|
|
"Fuck this place.",
|
|
|
|
"GREAT! If you're a penguin.",
|
|
|
|
"Fresh off the tap.",
|
2013-01-10 22:08:52 -05:00
|
|
|
"Fantastic do-nothing weather.",
|
2017-07-28 22:57:12 -04:00
|
|
|
"Put on some fucking socks.",
|
|
|
|
"Blue balls x 2",
|
2013-01-10 22:08:52 -05:00
|
|
|
"Good news, food won't spoil nearly as fast outside. Bad news, who cares?",
|
2017-07-28 22:57:12 -04:00
|
|
|
"Really?",
|
|
|
|
"Wear a fucking jacket.",
|
2013-01-10 22:08:52 -05:00
|
|
|
"I hear Siberia is the same this time of year.",
|
2017-07-28 22:57:12 -04:00
|
|
|
"NOT FUCKING JOGGING WEATHER",
|
|
|
|
"Shrinkage's best friend.",
|
|
|
|
"Warmer than Hoth.",
|
|
|
|
"Good baby making weather.",
|
2013-01-10 22:08:52 -05:00
|
|
|
"Where's a Tauntaun when you need one?",
|
2017-07-28 22:57:12 -04:00
|
|
|
"My nipples could cut glass",
|
|
|
|
"Global Warming? Bullshit.",
|
2013-01-10 22:08:52 -05:00
|
|
|
"Call your local travel agency and ask them if they're serious.",
|
|
|
|
"Freezing my balls off IN here",
|
2017-07-28 22:57:12 -04:00
|
|
|
"I'm not sure how you can stand it",
|
|
|
|
"I'm sorry.",
|
2013-01-10 22:08:52 -05:00
|
|
|
"Even penguins are wearing jackets.",
|
|
|
|
"Keep track of your local old people.",
|
|
|
|
"WHAT THE FUCK DO YOU MEAN IT'S NICER IN ALASKA?",
|
|
|
|
"Sock warmers are go. Everywhere.",
|
|
|
|
"Why does my car feel like a pair of ice skates?",
|
|
|
|
"Actually, a sharp-stick in the eye might not all be that bad right now.",
|
2017-07-28 22:57:12 -04:00
|
|
|
"THO Season.",
|
|
|
|
"It's a tit-bit nipplie.",
|
2013-01-10 22:08:52 -05:00
|
|
|
"Anything wooden will make a good fireplace. Thank us later.",
|
|
|
|
"MOVE THE FUCK ON GOLDILOCKS",
|
|
|
|
"I'm defrosting inside of my freezer.",
|
|
|
|
"It's time for a vacation.",
|
2017-07-28 22:57:12 -04:00
|
|
|
"It's bone chilling cold out. Sorry ladies."
|
|
|
|
]
|
2013-01-10 22:08:52 -05:00
|
|
|
elif w.temperature < 20:
|
|
|
|
remark = "IT'S FUCKING...ALRIGHT"
|
2013-10-01 01:40:03 -04:00
|
|
|
flavors = [
|
|
|
|
"Might as well rain, I'm not going out in that.",
|
2013-01-10 22:08:52 -05:00
|
|
|
"Better than a sharp stick in the eye.",
|
|
|
|
"Everything's nice butter weather!",
|
|
|
|
"At least you aren't living in a small town in Alaska",
|
2017-07-28 22:57:12 -04:00
|
|
|
"It could be worse.",
|
|
|
|
"FUCKING NOTHING TO SEE HERE",
|
2013-01-10 22:08:52 -05:00
|
|
|
"Listen, weather. We need to have a talk.",
|
|
|
|
"OH NO. THE WEATHER MACHINE IS BROKEN.",
|
|
|
|
"An Eskimo would beat your ass to be here",
|
|
|
|
"Where life is mediocre",
|
|
|
|
"Can't complain about today, but I want to!",
|
|
|
|
"Maybe inviting the inlaws over will improve today.",
|
|
|
|
"Let's go to the beach! In three months when it's nice again...",
|
|
|
|
"From inside it looks nice out.", "WHAT THE FUCK EVER",
|
|
|
|
"I love keeping the heat on for this long.",
|
|
|
|
"Inside or outside? Either way it's still today.",
|
|
|
|
"It's either only going to get better or worse from here!",
|
|
|
|
"If it's raining cats and dogs, hope you're not a pet person.",
|
|
|
|
"Today makes warm showers way nicer.",
|
|
|
|
"Here's to making your blankets feel useful.",
|
|
|
|
"I've seen better days",
|
|
|
|
"Compared to how awful it's been this is great!",
|
|
|
|
"If we go running maybe we won't notice.",
|
|
|
|
"Is that the sun outside? Why isn't it doing anything?",
|
|
|
|
"Well, at least we're not in prison.",
|
|
|
|
"Slap me around and call me Sally. It'd be an improvement.",
|
|
|
|
"Today is the perfect size, really honey.",
|
2017-07-28 22:57:12 -04:00
|
|
|
"It's that kind of day where you want zip off pants, until you realize how much of a jackass you look like in them.",
|
|
|
|
"Maybe Jersey Shore is on tonight.",
|
|
|
|
"Praise \"Bob\"!",
|
|
|
|
"Or kill me.",
|
|
|
|
"This statement is false.",
|
|
|
|
"Lies and slander, sire!"
|
|
|
|
]
|
2013-11-27 01:41:48 -05:00
|
|
|
elif w.temperature < 27:
|
2013-01-10 22:08:52 -05:00
|
|
|
remark = "IT'S FUCKING NICE"
|
2013-10-01 01:40:03 -04:00
|
|
|
flavors = [
|
2017-07-28 22:57:12 -04:00
|
|
|
"I made today breakfast in bed.",
|
|
|
|
"FUCKING SWEET",
|
|
|
|
"Quit your bitching",
|
|
|
|
"Enjoy.",
|
|
|
|
"IT'S ABOUT FUCKING TIME",
|
|
|
|
"READ A FUCKIN' BOOK",
|
|
|
|
"LETS HAVE A FUCKING PICNIC",
|
|
|
|
"It is safe to take your ball-mittens off.",
|
|
|
|
"More please.",
|
|
|
|
"uh, can we trade?",
|
|
|
|
"I approve of this message!",
|
|
|
|
"WE WERE BEGINNING TO THINK YOU LOST YOUR MIND",
|
|
|
|
"WOO, Spring Break!",
|
|
|
|
"I can't believe it's not porn!",
|
|
|
|
"I approve of this message!",
|
|
|
|
"Operation beach volleyball is go.",
|
|
|
|
"Plucky ducky kinda day.",
|
2013-01-10 22:08:52 -05:00
|
|
|
"Today called just to say \"Hi.\"",
|
|
|
|
"STOP AND SMELL THE FUCKING ROSES",
|
2017-07-28 22:57:12 -04:00
|
|
|
"FUCKING NOTHING WRONG WITH TODAY",
|
|
|
|
"LETS HAVE A FUCKING SOIREE",
|
2013-01-10 22:08:52 -05:00
|
|
|
"What would you do for a holyshititsniceout bar?",
|
|
|
|
"There are no rules today, blow shit up!",
|
|
|
|
"Celebrate Today's Day and buy your Today a present so it knows you care.",
|
|
|
|
"I feel bad about playing on my computer all day.",
|
2017-07-28 22:57:12 -04:00
|
|
|
"Party in the woods.",
|
|
|
|
"It is now safe to leave your home.",
|
2013-01-10 22:08:52 -05:00
|
|
|
"PUT A FUCKING CAPE ON TODAY, BECAUSE IT'S SUPER",
|
|
|
|
"Today is like \"ice\" if it started with an \"n\". Fuck you, we don't mean nce.",
|
|
|
|
"Water park! Water drive! Just get wet!",
|
|
|
|
"The geese are on their way back! Unless you live where they migrate to for the winter.",
|
2017-07-28 22:57:12 -04:00
|
|
|
"FUCKING AFFABLE AS SHIT",
|
|
|
|
"Give the sun a raise!",
|
|
|
|
"Go outside and go cycling or some shit, you fitness nerd!",
|
|
|
|
"Today is better than an original holographic Charizard. Loser!"
|
|
|
|
]
|
2013-11-27 01:41:48 -05:00
|
|
|
else:
|
|
|
|
remark = "IT'S FUCKING HOT"
|
|
|
|
flavors = [
|
|
|
|
"Do you have life insurance?",
|
|
|
|
"Like super models, IT'S TOO FUCKING HOT.",
|
|
|
|
"Not even PAM can make me not stick to this seat",
|
|
|
|
"SWIMMIN HOLE!",
|
|
|
|
"Time to crank the AC.",
|
2016-01-12 13:02:02 -05:00
|
|
|
"THE FUCKING EQUATOR CALLED, AND IT'S JEALOUS.",
|
2013-11-27 01:41:48 -05:00
|
|
|
"Looked in the fridge this morning for some eggs. They're already cooked.",
|
|
|
|
"Keeping the AC business in business.",
|
|
|
|
"I burned my feet walking on grass.",
|
|
|
|
"times you wish you didn't have leather seats",
|
|
|
|
"Isn't the desert nice this time of year?",
|
|
|
|
"Why, oh why did we decide to live in an oven?",
|
|
|
|
"It's hotter outside than my fever.",
|
2017-07-28 22:57:12 -04:00
|
|
|
"TAKE IT OFF!",
|
|
|
|
"TAKE FUCKING EVERYTHING OFF!",
|
|
|
|
"EVEN THAT NEEDS TO COME OFF!",
|
2013-11-27 01:41:48 -05:00
|
|
|
"Even your frigid girlfriend can't save you from today.",
|
|
|
|
"I need gloves to touch the steering wheel.",
|
2017-07-28 22:57:12 -04:00
|
|
|
"I can hear that power bill running up right now!",
|
2013-11-27 01:41:48 -05:00
|
|
|
"Lock up yo' ice cream trucks, lock up yo' wife.",
|
|
|
|
"FUCKING SUNBURNED, AND I WAS INSIDE ALL DAY.",
|
2017-07-28 22:57:12 -04:00
|
|
|
"Fuck this shit, I'm moving back to Alaska."
|
|
|
|
]
|
2013-10-01 01:40:03 -04:00
|
|
|
|
2013-01-10 22:08:52 -05:00
|
|
|
if w.descriptor == "thunderstorm":
|
|
|
|
remark += " AND THUNDERING"
|
2017-06-03 00:31:03 -04:00
|
|
|
flavors += [
|
|
|
|
"Are you sure you want to go out in that? I'm not",
|
2017-07-28 22:57:12 -04:00
|
|
|
"Fuck my ears!",
|
|
|
|
"Don't go flying a kite. Unless you're Ben Franklin",
|
2017-06-03 00:31:03 -04:00
|
|
|
"Did you think Eris would smile upon your failings?"
|
|
|
|
]
|
2013-01-10 22:08:52 -05:00
|
|
|
elif w.precipitation in ("snow", "snow grains"):
|
|
|
|
remark += " AND SNOWING"
|
2017-06-03 00:31:03 -04:00
|
|
|
flavors += [
|
|
|
|
"What's this white stuff that's sticking to everything?",
|
|
|
|
"At least that stuff doesn't glow in the dark!",
|
|
|
|
"How the fuck am I supposed to get around now?",
|
|
|
|
"And you thought four-wheel-drive would help you!",
|
|
|
|
"Go fight those cadets with snowballs",
|
2017-07-28 22:57:12 -04:00
|
|
|
"Where does the white go when the snow melts?",
|
|
|
|
"Just sNOw"
|
|
|
|
]
|
2013-01-10 22:08:52 -05:00
|
|
|
elif w.precipitation in ("drizzle", "rain", "unknown precipitation"):
|
|
|
|
remark += " AND WET"
|
2017-06-03 00:31:03 -04:00
|
|
|
flavors += [
|
2017-07-28 22:57:12 -04:00
|
|
|
"Just like your mom!",
|
|
|
|
"I guess it can't get much worse",
|
|
|
|
"Hope you have a rain coat",
|
|
|
|
"Shower outside?",
|
|
|
|
"If only more buildings had gargoyles..."
|
2017-06-03 00:31:03 -04:00
|
|
|
]
|
2013-01-10 22:08:52 -05:00
|
|
|
elif w.precipitation in ("ice crystals", "ice pellets"):
|
|
|
|
remark += " AND ICY"
|
2017-06-03 00:31:03 -04:00
|
|
|
flavors += [
|
2017-07-28 22:57:12 -04:00
|
|
|
"Nice, but without the N!",
|
|
|
|
"Where's some NaCl when you need it?",
|
|
|
|
"I hope your skates are nearby.",
|
|
|
|
"Studded tyres? What're those?"
|
|
|
|
]
|
2013-01-10 22:08:52 -05:00
|
|
|
elif w.precipitation in ("hail", "small hail"):
|
|
|
|
remark += " AND HAILING"
|
2017-06-03 00:31:03 -04:00
|
|
|
flavors += [
|
2017-07-28 22:57:12 -04:00
|
|
|
"Windshield damage!",
|
|
|
|
"Car alarms!",
|
|
|
|
"Lie face-down outside: free massage!"
|
|
|
|
]
|
2013-01-10 22:08:52 -05:00
|
|
|
|
2013-10-01 01:40:03 -04:00
|
|
|
if int(tempf) == 69:
|
2013-01-10 22:08:52 -05:00
|
|
|
remark = "IT'S FUCKING SEXY TIME"
|
2013-10-01 01:40:03 -04:00
|
|
|
flavors = [
|
|
|
|
"Why is 77 better than 69? You get eight more.",
|
|
|
|
"What comes after 69? Mouthwash.",
|
|
|
|
"If you are given two contradictory orders, obey them both.",
|
|
|
|
"a good fuckin' time! ;)",
|
2017-07-28 22:57:12 -04:00
|
|
|
"What's the square root of 69? Eight something."
|
|
|
|
]
|
2010-12-06 16:12:28 -05:00
|
|
|
|
2013-01-10 22:08:52 -05:00
|
|
|
flavor = random.choice(flavors)
|
2010-12-06 16:12:28 -05:00
|
|
|
|
2013-01-10 22:08:52 -05:00
|
|
|
response = "{temp} {remark} - {flavor} - {location} {time}Z".format(
|
2013-10-01 01:40:03 -04:00
|
|
|
temp=temp, remark=remark, flavor=flavor, location=w.station,
|
|
|
|
time=w.time.strftime("%H:%M"))
|
2011-12-04 19:46:28 -05:00
|
|
|
phenny.say(response)
|
2014-04-25 16:30:41 -04:00
|
|
|
tfw.rule = (['tfw', 'tfwm'], r'(.*)')
|
2010-12-06 16:12:28 -05:00
|
|
|
|
2013-10-01 01:40:03 -04:00
|
|
|
|
2011-04-04 16:37:27 -04:00
|
|
|
def tfwf(phenny, input):
|
2011-12-04 19:46:28 -05:00
|
|
|
""".tfwf <city/zip> - The fucking weather, in fucking degrees Fahrenheit."""
|
|
|
|
return tfw(phenny, input, fahrenheit=True)
|
2011-04-04 16:37:27 -04:00
|
|
|
tfwf.rule = (['tfwf'], r'(.*)')
|
|
|
|
|
2013-10-01 01:40:03 -04:00
|
|
|
|
2010-12-08 22:00:54 -05:00
|
|
|
def tfwc(phenny, input):
|
2011-12-04 19:46:28 -05:00
|
|
|
""".tfwc <city/zip> - The fucking weather, in fucking degrees celsius."""
|
|
|
|
return tfw(phenny, input, celsius=True)
|
2010-12-08 22:00:54 -05:00
|
|
|
tfwc.rule = (['tfwc'], r'(.*)')
|
|
|
|
|
2014-04-25 20:27:50 -04:00
|
|
|
def tfwev(phenny, input):
|
2017-11-04 12:32:54 -04:00
|
|
|
""".tfwev <city/zip> - The fucking weather, in fucking electron volts."""
|
2014-04-25 20:27:50 -04:00
|
|
|
return tfw(phenny, input, mev=True)
|
|
|
|
tfwev.rule = (['tfwev'], r'(.*)')
|
2013-10-01 01:40:03 -04:00
|
|
|
|
2010-12-06 16:12:28 -05:00
|
|
|
if __name__ == '__main__':
|
2011-12-04 19:46:28 -05:00
|
|
|
print(__doc__.strip())
|