From b8c3fe073b9802847ff46c30092fcf4f66f32424 Mon Sep 17 00:00:00 2001 From: jkhsjdhjs Date: Sat, 15 May 2021 14:26:56 +0000 Subject: [PATCH] urban: fix multi-word terms --- bot/urban.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bot/urban.py b/bot/urban.py index 261b7e2..9391343 100644 --- a/bot/urban.py +++ b/bot/urban.py @@ -17,7 +17,7 @@ class Urban(Plugin): %%ud ... """ # Clean, strip and split term by whitespace - term = ' '.join(args.get('')).lower().strip().split() + term = ' '.join(args.get('')).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