diff options
| author | 2019-11-25 18:17:30 +0000 | |
|---|---|---|
| committer | 2019-11-25 18:17:30 +0000 | |
| commit | 6a6e789ec9e3c6dd365922ac630a405b830e8c1a (patch) | |
| tree | 7e2e1675d7d1fab7d4240da83c0179076f89c938 /modules/define.py | |
| parent | include <title> with !google/!g output (diff) | |
| signature | ||
add `cookies` and `.json()` to utils.http.Response objects
Diffstat (limited to 'modules/define.py')
| -rw-r--r-- | modules/define.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/modules/define.py b/modules/define.py index 144ec227..4e83c65c 100644 --- a/modules/define.py +++ b/modules/define.py @@ -15,12 +15,12 @@ class Module(ModuleManager.BaseModule): def _get_definition(self, word): 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) + "sourceDictionaries": "wiktionary", + "api_key": self.bot.config["wordnik-api-key"]}) if page: if page.code == 200: - return True, page.data[0] + return True, page.json()[0] else: return True, None else: @@ -58,16 +58,16 @@ class Module(ModuleManager.BaseModule): self._last_called = time.time() 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.data): - success, definition = self._get_definition(page.data["word"]) + "api_key": self.bot.config["wordnik-api-key"], + "min_dictionary_count": 1}).json() + if page: + success, definition = self._get_definition(page["word"]) if not success: raise utils.EventError("Try again in a couple of seconds") text = utils.http.strip_html(definition["text"]) event["stdout"].write("Random Word: %s - Definition: %s" % ( - page.data["word"], text)) + page["word"], text)) else: raise utils.EventResultsError() else: |
