From 14e61392e1c842435384ed6cbadbee19e937540b Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Thu, 18 Apr 2013 11:59:32 -0300 Subject: [PATCH] Handle newlines (somewhat) correctly? --- commands/urbandictionary.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/commands/urbandictionary.py b/commands/urbandictionary.py index ec206c2..4480500 100644 --- a/commands/urbandictionary.py +++ b/commands/urbandictionary.py @@ -25,8 +25,9 @@ class UrbanDictionary(Command): query = urlopen(url.format(q)).read() res = loads(query) if res['result_type'] == 'exact': - defin = res['list'][0] - msg = 'Definition: {definition}; example: {example}'.format(**defin) + definition = res['list'][0]['definition'].replace("\n", " ") + example = res['list'][0]['example'].replace("\n", " ") + msg = 'Definition: {0}; example: {1}'.format(definition, example) self.reply(data, msg) elif res['result_type'] == 'fulltext': L = [i['word'] for i in res['list']]