removing weather. you can just use the ask feature

This commit is contained in:
Luke Robles 2021-08-16 19:05:08 -07:00
parent 8f09183295
commit e3e2770a7d
3 changed files with 1 additions and 45 deletions

View File

@ -53,13 +53,6 @@ async def ask(ctx):
questions.answer_question(ctx.message.content),
)
@bot.command(name='raws')
async def raws(ctx):
import weather
await ctx.send(
embed=weather.parse_message(ctx.message.content)
)
@bot.command(name='invite')
async def invite(ctx):
# Default to creating the invite to the channel the message was sent in

View File

@ -6,4 +6,3 @@ pandas
requests
wikipedia
wolframalpha
pyowm

View File

@ -1,36 +0,0 @@
from pyowm.owm import OWM
import discord
import os
# import pprint
# pp = pprint.PrettyPrinter(indent=4)
def parse_message(message):
location = message.split()[1:]
print(location)
return get_weather(' '.join(location))
def get_weather(location):
# owm = OWM('614e00c15660f75756544b83d556fe75')
owm = OWM(os.getenv('weather_api_key'))
mgr = owm.weather_manager()
observation = mgr.weather_at_place(location) # the observation object is a box containing a weather object
weather = observation.weather
wind_data = weather.wind(unit='miles_hour')
wind_speed = wind_data['speed']
wind_direction = degToCompass(wind_data['deg'])
embed = discord.Embed(description="Weather for %s" % location, color=5793266, type="rich")
embed.add_field(name='Current weather', value=weather.detailed_status, inline=False)
embed.add_field(name='Wind', value="**Wind Speed**: %s, **Wind Direction**: %s" % (wind_speed, wind_direction), inline=False)
embed.add_field(name='Temperature (F)', value=weather.temperature('fahrenheit'), inline=False)
embed.add_field(name='Humidity', value=str(weather.humidity) + '%', inline=False)
return embed
def degToCompass(num):
val=int((num/22.5)+.5)
arr=["N","NNE","NE","ENE","E","ESE", "SE", "SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"]
return arr[(val % 16)]