From c93d99147a4bcca53b85b10cbf4903dcae048e7b Mon Sep 17 00:00:00 2001 From: Ryan Hitchman Date: Fri, 3 Apr 2009 12:40:53 -0600 Subject: [PATCH] in-irc documentation for wikipedia --- plugins/wikipedia.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/wikipedia.py b/plugins/wikipedia.py index 659b603..6c4567f 100644 --- a/plugins/wikipedia.py +++ b/plugins/wikipedia.py @@ -13,12 +13,15 @@ search_url = api_prefix + "?action=opensearch&search=%s&format=xml" paren_re = re.compile('\s*\(.*\)$') -@hook.command(hook='w (.*)') +@hook.command(hook='w(\s+.*|$)') @hook.command def wiki(query): - print query - q = search_url % (urllib.quote(query, safe='')) - print q + '''.w/.wiki -- gets first sentence of wikipedia article on ''' + + if not query.strip(): + return wiki.__doc__ + + q = search_url % (urllib.quote(query.strip(), safe='')) x = etree.parse(q) ns = '{http://opensearch.org/searchsuggest2}'