瀏覽代碼

Handle newlines (somewhat) correctly?

pull/9/head
Ben Kurtovic 11 年之前
父節點
當前提交
14e61392e1
共有 1 個檔案被更改,包括 3 行新增2 行删除
  1. +3
    -2
      commands/urbandictionary.py

+ 3
- 2
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']]


Loading…
取消
儲存