-
Notifications
You must be signed in to change notification settings - Fork 990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weather add #13
Weather add #13
Changes from 1 commit
0a8fad2
c28f576
98ecac2
f2232f7
3de7e86
200ec6e
30c6f28
fd255ac
d34d213
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,6 @@ | |
'help', | ||
'joke', | ||
'movie', | ||
'request' | ||
'request', | ||
'weather' | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import re | ||
import requests | ||
|
||
def process(input, entities=None): | ||
output = {} | ||
|
||
try: | ||
city = entities['city'][0]['value'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change city to location |
||
r = requests.get('http://api.openweathermap.org/data/2.5/weather?q=' + city + '&appid=adee94563461cdf1dcfe25956aea10ae') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. appid needs to go in config.py |
||
data = r.json() | ||
output['input'] = input | ||
output['output'] = 'Current weather: ' + data['main.temp'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. access it as |
||
output['success'] = True | ||
except: | ||
output['success'] = False | ||
return output |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import modules | ||
|
||
def test_request(): | ||
assert('request' == modules.process_query('request')[0]) | ||
assert('request' == modules.process_query('report')[0]) | ||
assert('request' != modules.process_query('something random')[0]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add some relevant tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to make this PR about weather only (so that someone can refer it in the future for adding another module). Can you make another PR with this change?