minor fixes for twitter/wikipedia

This commit is contained in:
Ryan Hitchman 2009-03-24 16:53:56 -06:00
parent 1456823de8
commit 87520d951d
3 changed files with 9 additions and 4 deletions

View File

@ -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

View File

@ -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"

View File

@ -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')]