This commit is contained in:
Jason Ji 2017-09-22 03:53:06 +00:00 committed by Luke Robles
parent bbfe817d9d
commit c134178456
3 changed files with 24 additions and 4 deletions

View File

@ -20,6 +20,7 @@ import help_methods
import lewds
import role_check
import wallpaper
import weather
import wolfram
# Client object
@ -117,6 +118,12 @@ async def on_message(message):
lewds.get_lewd(channel_name=message.channel.name)
)
if message.content.startswith('!weather'):
await client.send_message(
message.channel,
weather.get_weather(message.content)
)
if message.content.startswith('!purge'):
num = 20
if len(message.content.split()) > 1:

View File

@ -59,7 +59,10 @@ def get_help_message(method):
'This function now outputs the SWEET-ASS picture of the day.',
' Note this picture only changes once a day.',
'\nUsage: !homepage'
]
],
'weather': [
'Returns the weather for the location you entered.',
'\nUsage: !weather Berkeley']
}
# Print out every help method

View File

@ -7,8 +7,19 @@ emojis = {'clear sky': ':sunny:', 'scattered clouds': ':partly_sunny:',
'light rain': ':white_sun_rain_cloud:', 'overcast clouds': ':cloud:',
'broken clouds': ':white_sun_cloud:', 'moderate rain': ':cloud_with_rain:',
'light snow': ':cloud_snow:', 'few clouds': ':white_sun_small_cloud:'}
openweathermap = OWM('593e0e182f9278a10443da354c4014db')
def get_weather(location):
def parse_loc(message):
if len(message.split()) > 1:
try:
res = get_weather(' '.join(message.split()[1:]))
except exceptions.api_call_error.APICallError:
res = '```Please input a valid location: !weather [location]```'
return res
return '```Please input a valid location: !weather [location]```'
def get_weather(message):
"""
get_weather(location)
@ -18,8 +29,7 @@ def get_weather(location):
TODO: Replace basic code block with nice looking, bold text w/ emojis
"""
try:
openweathermap = OWM('593e0e182f9278a10443da354c4014db')
forecaster = openweathermap.three_hours_forecast(location)
forecaster = openweathermap.three_hours_forecast(message)
forecast = forecaster.get_forecast()
reg = forecast.get(0)