removing weather. you can just use the ask feature
This commit is contained in:
parent
8f09183295
commit
e3e2770a7d
@ -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
|
||||
|
@ -5,5 +5,4 @@ lxml
|
||||
pandas
|
||||
requests
|
||||
wikipedia
|
||||
wolframalpha
|
||||
pyowm
|
||||
wolframalpha
|
@ -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)]
|
Loading…
x
Reference in New Issue
Block a user