From 87520d951d2d0cde211d9394fa6962aee694ae68 Mon Sep 17 00:00:00 2001 From: Ryan Hitchman Date: Tue, 24 Mar 2009 16:53:56 -0600 Subject: [PATCH] minor fixes for twitter/wikipedia --- plugins/sieve.py | 3 +-- plugins/twitter.py | 5 ++++- plugins/wikipedia.py | 5 ++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/sieve.py b/plugins/sieve.py index 3efdc5c..db921e5 100644 --- a/plugins/sieve.py +++ b/plugins/sieve.py @@ -24,7 +24,6 @@ def sieve_suite(bot, input, func, args): if input.re is None: return None - input.inp = (' '.join(input.re.groups()) + - input.msg[input.re.span()[1]:]).strip() + input.inp = ' '.join(input.re.groups()) return input diff --git a/plugins/twitter.py b/plugins/twitter.py index 1ed1435..b17c026 100644 --- a/plugins/twitter.py +++ b/plugins/twitter.py @@ -16,7 +16,10 @@ def twitter(bot, input): url = "http://twitter.com/statuses/user_timeline/%s.xml?count=1" \ % urllib.quote(input.inp) - tweet = etree.parse(url) + try: + tweet = etree.parse(url) + except IOError: + return 'RoR: XTREME scalability (twitter is unresponsive)' if tweet.find('error') is not None: return "can't find that username" diff --git a/plugins/wikipedia.py b/plugins/wikipedia.py index a24bcdc..0ff476c 100644 --- a/plugins/wikipedia.py +++ b/plugins/wikipedia.py @@ -13,7 +13,7 @@ search_url = api_prefix + "?action=opensearch&search=%s&format=xml" paren_re = re.compile('\s*\(.*\)$') -@hook.command(hook='w') +@hook.command(hook='w (.*)') @hook.command def wiki(query): print query @@ -24,6 +24,9 @@ def wiki(query): ns = '{http://opensearch.org/searchsuggest2}' items = x.findall(ns + 'Section/' + ns + 'Item') + if items == []: + return 'no results found' + def extract(item): return [item.find(ns + x).text for x in ('Text', 'Description', 'Url')]