From 927fcaa52177751b785936d0e2fd34057459c43b Mon Sep 17 00:00:00 2001 From: novokrest Date: Fri, 11 May 2018 07:54:53 +0300 Subject: [PATCH] susi: Pass API query parameters as `params` dict in requests.get(). --- zulip_bots/zulip_bots/bots/susi/fixtures/test_reply.json | 5 ++++- zulip_bots/zulip_bots/bots/susi/susi.py | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/zulip_bots/zulip_bots/bots/susi/fixtures/test_reply.json b/zulip_bots/zulip_bots/bots/susi/fixtures/test_reply.json index 3079fce..fd6fc7f 100644 --- a/zulip_bots/zulip_bots/bots/susi/fixtures/test_reply.json +++ b/zulip_bots/zulip_bots/bots/susi/fixtures/test_reply.json @@ -1,6 +1,9 @@ { "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": { "query": "hi", diff --git a/zulip_bots/zulip_bots/bots/susi/susi.py b/zulip_bots/zulip_bots/bots/susi/susi.py index 03e162b..63c54a8 100644 --- a/zulip_bots/zulip_bots/bots/susi/susi.py +++ b/zulip_bots/zulip_bots/bots/susi/susi.py @@ -1,5 +1,4 @@ import requests -import urllib from typing import Dict, Any, Tuple, Union class SusiHandler(object): @@ -40,8 +39,7 @@ class SusiHandler(object): if msg == 'help' or msg == '': bot_handler.send_reply(message, self.usage()) return - encoded_msg = urllib.parse.quote_plus(msg.encode('utf8')) - reply = requests.get("https://api.susi.ai/susi/chat.json?q=" + encoded_msg) + reply = requests.get("https://api.susi.ai/susi/chat.json", params=dict(q=msg)) try: answer = reply.json()['answers'][0]['actions'][0]['expression'] except Exception: