diff options
| author | 2019-11-26 13:41:40 +0000 | |
|---|---|---|
| committer | 2019-11-26 13:42:01 +0000 | |
| commit | 2d21dfa22931bdb887ccccba4a33e6fa4755e94b (patch) | |
| tree | 6ef5e304e3e9a69f9afd66ac0bee4d98ec115399 /modules/thesaurus.py | |
| parent | remove all `eagle` stuff from nr.py (diff) | |
| signature | ||
utils.http.Response.data should always be `bytes` - add .decode and .soup
Diffstat (limited to 'modules/thesaurus.py')
| -rw-r--r-- | modules/thesaurus.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/modules/thesaurus.py b/modules/thesaurus.py index df988c9e..bd30e67e 100644 --- a/modules/thesaurus.py +++ b/modules/thesaurus.py @@ -14,17 +14,18 @@ class Module(ModuleManager.BaseModule): :usage: <word> [type] """ phrase = event["args_split"][0] - page = utils.http.request(URL_THESAURUS % (self.bot.config[ - "bighugethesaurus-api-key"], phrase), json=True) + page = utils.http.request(URL_THESAURUS % ( + self.bot.config["bighugethesaurus-api-key"], phrase)) syn_ant = event["command"][:3] if page: if page.code == 404: raise utils.EventError("Word not found") + page = page.json() if not len(event["args_split"]) > 1: word_types = [] - for word_type in page.data.keys(): - if syn_ant in page.data[word_type]: + for word_type in page.keys(): + if syn_ant in page[word_type]: word_types.append(word_type) if word_types: word_types = sorted(word_types) @@ -35,11 +36,11 @@ class Module(ModuleManager.BaseModule): event["stderr"].write("No categories available") else: category = event["args_split"][1].lower() - if category in page.data: - if syn_ant in page.data[category]: + if category in page: + if syn_ant in page[category]: event["stdout"].write("%ss for %s: %s" % ( event["command"].title(), phrase, ", ".join( - page.data[category][syn_ant]))) + page[category][syn_ant]))) else: event["stderr"].write("No %ss for %s" % ( event["command"], phrase)) |
