From 7097a266c6d9d5adec10f7f890eed76608e04342 Mon Sep 17 00:00:00 2001 From: Jason Ji Date: Fri, 22 Sep 2017 03:53:06 +0000 Subject: [PATCH 1/4] Weather --- app/dragon-bot.py | 7 +++++++ app/help_methods.py | 5 ++++- app/weather.py | 16 +++++++++++++--- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/dragon-bot.py b/app/dragon-bot.py index 113078bd..71462400 100644 --- a/app/dragon-bot.py +++ b/app/dragon-bot.py @@ -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: diff --git a/app/help_methods.py b/app/help_methods.py index 647e3731..9c3b9fcf 100644 --- a/app/help_methods.py +++ b/app/help_methods.py @@ -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 diff --git a/app/weather.py b/app/weather.py index 311ae871..233766cb 100644 --- a/app/weather.py +++ b/app/weather.py @@ -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) From 6f3d6db5d60e79e4b9cbfbe62d36321071efd156 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Thu, 21 Sep 2017 21:31:54 -0700 Subject: [PATCH 2/4] Adding pout --- app/dragon-bot.py | 6 ++++++ app/help_methods.py | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/dragon-bot.py b/app/dragon-bot.py index 71462400..db020689 100644 --- a/app/dragon-bot.py +++ b/app/dragon-bot.py @@ -124,6 +124,12 @@ async def on_message(message): weather.get_weather(message.content) ) + if message.content.startswith('!pout'): + await client.send_message( + message.channel, + get_from_reddit.get_image('pouts') + ) + if message.content.startswith('!purge'): num = 20 if len(message.content.split()) > 1: diff --git a/app/help_methods.py b/app/help_methods.py index 9c3b9fcf..693b97e2 100644 --- a/app/help_methods.py +++ b/app/help_methods.py @@ -62,7 +62,8 @@ def get_help_message(method): ], 'weather': [ 'Returns the weather for the location you entered.', - '\nUsage: !weather Berkeley'] + '\nUsage: !weather Berkeley'], + 'pout': ['Returns the URL for an anime girl pouting you filthy weeb'] } # Print out every help method From 975358d003bd49b08fd983cf5fbfdfb03368321c Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Fri, 22 Sep 2017 05:20:37 +0000 Subject: [PATCH 3/4] Fixing the fucked up help output --- app/help_methods.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/app/help_methods.py b/app/help_methods.py index 9c3b9fcf..856f2709 100644 --- a/app/help_methods.py +++ b/app/help_methods.py @@ -77,16 +77,14 @@ def get_help_message(method): # Join key : value of the help method they passed in message = "{} : {}".format(method, ' '.join(supported_methods[method])) - # Return the message wrapped in css formatting so we get pretty colors - return "```css\n{}\n```".format(message) + return "\n{}\n".format(message) def parse_message(message): + method = 'show_all' if len(message.split()) > 1: method = message.split()[1] - try: - explanation = get_help_message(method) - except KeyError: - return "I can't help you with that" - return "```css\n{}\n```".format(explanation) - - return get_help_message('show_all') + try: + explanation = get_help_message(method) + except KeyError: + return "I can't help you with that" + return "```css\n{}\n```".format(explanation) From 6d1b09bb1699210b7638d8bc99184dafae978e3e Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Fri, 22 Sep 2017 13:00:22 -0700 Subject: [PATCH 4/4] Smug faces yall --- app/dragon-bot.py | 6 ++++++ app/help_methods.py | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/dragon-bot.py b/app/dragon-bot.py index db020689..d25ce402 100644 --- a/app/dragon-bot.py +++ b/app/dragon-bot.py @@ -130,6 +130,12 @@ async def on_message(message): get_from_reddit.get_image('pouts') ) + if message.content.startswith('!smug'): + await client.send_message( + message.channel, + get_from_reddit.get_image('smuganimegirls') + ) + if message.content.startswith('!purge'): num = 20 if len(message.content.split()) > 1: diff --git a/app/help_methods.py b/app/help_methods.py index 37bcc96a..9a0f9f58 100644 --- a/app/help_methods.py +++ b/app/help_methods.py @@ -62,8 +62,14 @@ def get_help_message(method): ], 'weather': [ 'Returns the weather for the location you entered.', - '\nUsage: !weather Berkeley'], - 'pout': ['Returns the URL for an anime girl pouting you filthy weeb'] + '\nUsage: !weather Berkeley' + ], + 'pout': [ + 'Returns the URL for an anime girl pouting you filthy weeb' + ], + 'smug': [ + 'Returns the URL for smug anime girl' + ] } # Print out every help method