aboutsummaryrefslogtreecommitdiff
path: root/modules/define.py
diff options
context:
space:
mode:
authorGravatar jesopo2018-12-11 22:26:38 +0000
committerGravatar jesopo2018-12-11 22:26:38 +0000
commit793d234a0b924c0330e88f07f68b13559b42e4ac (patch)
tree90ecd3746a77e17da915f90ec057cb16ead82c05 /modules/define.py
parentActually use `action_desc` in github.py.issues, so that we can see what things (diff)
signature
'utils.http.get_url' -> 'utils.http.request', return a Response object from
utils.http.request
Diffstat (limited to 'modules/define.py')
-rw-r--r--modules/define.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/modules/define.py b/modules/define.py
index b86687c0..862e07eb 100644
--- a/modules/define.py
+++ b/modules/define.py
@@ -12,7 +12,7 @@ class Module(ModuleManager.BaseModule):
_last_called = 0
def _get_definition(self, word):
- page = utils.http.get_url(URL_WORDNIK % word, get_params={
+ page = utils.http.request(URL_WORDNIK % word, get_params={
"useCanonical": "true", "limit": 1,
"sourceDictionaries": "wiktionary", "api_key": self.bot.config[
"wordnik-api-key"]}, json=True)
@@ -33,9 +33,9 @@ class Module(ModuleManager.BaseModule):
page = self._get_definition(word)
if page:
- if len(page):
- event["stdout"].write("%s: %s" % (page[0]["word"],
- page[0]["text"]))
+ if len(page.data):
+ event["stdout"].write("%s: %s" % (page.data[0]["word"],
+ page.data[0]["text"]))
else:
event["stderr"].write("No definitions found")
else:
@@ -50,13 +50,13 @@ class Module(ModuleManager.BaseModule):
RANDOM_DELAY_SECONDS):
self._last_called = time.time()
- page = utils.http.get_url(URL_WORDNIK_RANDOM, get_params={
+ page = utils.http.request(URL_WORDNIK_RANDOM, get_params={
"api_key":self.bot.config["wordnik-api-key"],
"min_dictionary_count":1},json=True)
- if page and len(page):
- definition = self._get_definition(page["word"])
- if len(definition):
- definition = definition[0]
+ if page and len(page.data):
+ definition = self._get_definition(page.data["word"])
+ if definition and len(definition.data):
+ definition = definition.data[0]
else:
raise utils.EventError("Try again in a couple of seconds")