urban: fix multi-word terms

This commit is contained in:
jkhsjdhjs 2021-05-15 14:26:56 +00:00
parent 9a3fce367a
commit b8c3fe073b

View File

@ -17,7 +17,7 @@ class Urban(Plugin):
%%ud <term>...
"""
# Clean, strip and split term by whitespace
term = ' '.join(args.get('<term>')).lower().strip().split()
term = ' '.join(args.get('<term>')).lower().strip()
if term[-1].isdigit():
# Parse number at end as index - 1 and slice term
@ -30,6 +30,9 @@ class Urban(Plugin):
# Fetch data for term from urban dictionary as json
data = requests.get(self.URL, params=dict(term=term)).json()
if data.get("list") is None:
return "API Error"
res_length = len(data['list'])
# No results