diff --git a/plugins/minecraft_wiki.py b/plugins/minecraft_wiki.py index fe9aaea..aefc4d0 100755 --- a/plugins/minecraft_wiki.py +++ b/plugins/minecraft_wiki.py @@ -23,7 +23,7 @@ def mcwiki(inp): if p.text_content(): summary = " ".join(p.text_content().splitlines()) summary = re.sub("\[\d+\]", "", summary) - summary = text.truncate_str(summary, 250) - return "%s :: \x02%s\x02" % (summary, url) + summary = text.truncate_str(summary, 200) + return "%s :: %s" % (summary, url) return "Unknown Error." diff --git a/plugins/urban.py b/plugins/urban.py index 376b124..46ee3d6 100755 --- a/plugins/urban.py +++ b/plugins/urban.py @@ -1,4 +1,5 @@ -from util import hook, http, text +from util import hook, http, text, web +import re base_url = 'http://www.urbandictionary.com/iphone/search/define' @@ -21,19 +22,26 @@ def urban(inp): else: id = 1 + # fetch the definitions page = http.get_json(base_url, term=input, referer="http://m.urbandictionary.com") defs = page['list'] + print page if page['result_type'] == 'no_results': return 'Not found.' # try getting the requested definition try: - output = u"[%i/%i] %s: %s" % \ - (id, len(defs), defs[id - 1]['word'], - defs[id - 1]['definition'].replace('\r\n', ' ')) + definition = defs[id - 1]['definition'].replace('\r\n', ' ') + definition = re.sub('\s+', ' ', definition).strip() # remove excess spaces + definition = text.truncate_str(definition, 200) except IndexError: return 'Not found.' - return text.truncate_str(output, 250) + url = defs[id - 1]['permalink'] + + output = u"[%i/%i] %s :: %s" % \ + (id, len(defs), definition, url) + + return output diff --git a/plugins/wikipedia.py b/plugins/wikipedia.py index f82dd6a..a91003e 100755 --- a/plugins/wikipedia.py +++ b/plugins/wikipedia.py @@ -44,6 +44,6 @@ def wiki(inp): desc = re.sub('\s+', ' ', desc).strip() # remove excess spaces - desc = text.truncate_str(desc, 250) + desc = text.truncate_str(desc, 200) - return '%s -- %s' % (desc, http.quote(url, ':/')) + return '%s :: %s' % (desc, http.quote(url, ':/'))