it works lol
This commit is contained in:
parent
2d3d8cf10d
commit
9b42ebfb16
@ -2,7 +2,7 @@ FROM python:3.6.2-alpine3.6
|
|||||||
LABEL name="Dragon Bot Test environment"
|
LABEL name="Dragon Bot Test environment"
|
||||||
RUN apk update && apk add --no-cache vim docker
|
RUN apk update && apk add --no-cache vim docker
|
||||||
|
|
||||||
RUN pip install requests discord.py docker pylint wolframalpha
|
RUN pip install requests discord.py docker pylint wolframalpha pyowm
|
||||||
ADD app /app
|
ADD app /app
|
||||||
|
|
||||||
RUN printf "\n\nTesting your python code for errors\n\n" && \
|
RUN printf "\n\nTesting your python code for errors\n\n" && \
|
||||||
|
@ -1,24 +1,28 @@
|
|||||||
import requests
|
import requests
|
||||||
from pyowm import OWM
|
from pyowm import OWM
|
||||||
|
|
||||||
def get_weather(zip_code):
|
def get_weather(location):
|
||||||
"""
|
"""
|
||||||
get_weather(zip_code)
|
get_weather(location)
|
||||||
|
|
||||||
Returns the weather forecast for the selected zip code. Uses PythonOWM to
|
Returns the weather forecast for the selected zip code. Uses PythonOWM to
|
||||||
make life super easy.
|
make life super easy.
|
||||||
|
|
||||||
|
TODO: Replace basic code block with nice looking, bold text w/ emojis
|
||||||
"""
|
"""
|
||||||
owm = OWM('593e0e182f9278a10443da354c4014db')
|
owm = OWM('593e0e182f9278a10443da354c4014db')
|
||||||
fc = owm.three_hours_forecast(zip_code)
|
fc = owm.three_hours_forecast(location)
|
||||||
f = fc.get_forecast()
|
f = fc.get_forecast()
|
||||||
|
|
||||||
reg = f.get(0)
|
reg = f.get(0)
|
||||||
indicator = int(reg.get_reference_time(timeformat='iso')[11:13]) // 3
|
indicator = int(reg.get_reference_time(timeformat='iso')[11:13]) // 3
|
||||||
|
|
||||||
ret = ''
|
ret = '```'
|
||||||
|
|
||||||
ret = ret + ('Status: ' + reg.get_detailed_status() + ' '
|
ret = ret + ('\nStatus: ' + reg.get_detailed_status() + ' ' +
|
||||||
'Current Temperature: ' + str(reg.get_temperature('fahrenheit').get('temp')) + '\n')
|
'Current Temperature: ' +
|
||||||
|
str(reg.get_temperature('fahrenheit').get('temp')) +
|
||||||
|
'F\n\nFive day forecast:\n')
|
||||||
|
|
||||||
for i in range((4 - indicator) % 8, len(f), 8):
|
for i in range((4 - indicator) % 8, len(f), 8):
|
||||||
high, low = 0, 100000
|
high, low = 0, 100000
|
||||||
@ -37,11 +41,8 @@ def get_weather(zip_code):
|
|||||||
if low > l:
|
if low > l:
|
||||||
low = l
|
low = l
|
||||||
|
|
||||||
ret = ret + ('Status: ' + f.get(i).get_detailed_status() + ' '
|
ret = ret + '{:<30}'.format('Status: ' + f.get(i).get_detailed_status())
|
||||||
'High: ' + str(high) + ' '
|
ret = ret + '{:<18}'.format('High: ' + str(high) + 'F ')
|
||||||
'Low: ' + str(low) + ' '
|
ret = ret + 'Low: ' + str(low) + 'F\n'
|
||||||
'Date: ' +
|
|
||||||
str(f.get(i).get_reference_time(timeformat='iso'))[:10] + '\n')
|
|
||||||
|
|
||||||
# print(ret)
|
return ret + '```'
|
||||||
return ret
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user