From d65914cc17fa506f7e94c840d9316f7b3fd12ce3 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Wed, 6 Apr 2016 00:02:48 -0500 Subject: [PATCH] Add URL to !urban --- commands/urbandictionary.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/commands/urbandictionary.py b/commands/urbandictionary.py index a476834..1c241dd 100644 --- a/commands/urbandictionary.py +++ b/commands/urbandictionary.py @@ -27,10 +27,11 @@ class UrbanDictionary(Command): if res['result_type'] == 'exact': definition = re.sub(r"\s+", " ", res['list'][0]['definition']) example = re.sub(r"\s+", " ", res['list'][0]['example']) + url = res['list'][0]['permalink'].rsplit('/', 1)[0] if definition and definition[-1] not in (".", "!", "?"): definition += "." - msg = '{0} \x02Example\x0F: {1}'.format(definition.encode("utf8"), - example.encode("utf8")) + msg = '{0} \x02Example\x0F: {1} {2}'.format( + definition.encode("utf8"), example.encode("utf8"), url) self.reply(data, msg) elif res['result_type'] == 'fulltext': L = [i['word'] for i in res['list']]