susi: Pass API query parameters as params
dict in requests.get().
This commit is contained in:
parent
86ffbb2b4a
commit
927fcaa521
|
@ -1,6 +1,9 @@
|
||||||
{
|
{
|
||||||
"request": {
|
"request": {
|
||||||
"api_url": "https://api.susi.ai/susi/chat.json?q=hi"
|
"api_url": "https://api.susi.ai/susi/chat.json",
|
||||||
|
"params": {
|
||||||
|
"q": "hi"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"response": {
|
"response": {
|
||||||
"query": "hi",
|
"query": "hi",
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import requests
|
import requests
|
||||||
import urllib
|
|
||||||
from typing import Dict, Any, Tuple, Union
|
from typing import Dict, Any, Tuple, Union
|
||||||
|
|
||||||
class SusiHandler(object):
|
class SusiHandler(object):
|
||||||
|
@ -40,8 +39,7 @@ class SusiHandler(object):
|
||||||
if msg == 'help' or msg == '':
|
if msg == 'help' or msg == '':
|
||||||
bot_handler.send_reply(message, self.usage())
|
bot_handler.send_reply(message, self.usage())
|
||||||
return
|
return
|
||||||
encoded_msg = urllib.parse.quote_plus(msg.encode('utf8'))
|
reply = requests.get("https://api.susi.ai/susi/chat.json", params=dict(q=msg))
|
||||||
reply = requests.get("https://api.susi.ai/susi/chat.json?q=" + encoded_msg)
|
|
||||||
try:
|
try:
|
||||||
answer = reply.json()['answers'][0]['actions'][0]['expression']
|
answer = reply.json()['answers'][0]['actions'][0]['expression']
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
Loading…
Reference in a new issue