minor fixes for twitter/wikipedia
This commit is contained in:
parent
1456823de8
commit
87520d951d
|
@ -24,7 +24,6 @@ def sieve_suite(bot, input, func, args):
|
||||||
if input.re is None:
|
if input.re is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
input.inp = (' '.join(input.re.groups()) +
|
input.inp = ' '.join(input.re.groups())
|
||||||
input.msg[input.re.span()[1]:]).strip()
|
|
||||||
|
|
||||||
return input
|
return input
|
||||||
|
|
|
@ -16,7 +16,10 @@ def twitter(bot, input):
|
||||||
|
|
||||||
url = "http://twitter.com/statuses/user_timeline/%s.xml?count=1" \
|
url = "http://twitter.com/statuses/user_timeline/%s.xml?count=1" \
|
||||||
% urllib.quote(input.inp)
|
% 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:
|
if tweet.find('error') is not None:
|
||||||
return "can't find that username"
|
return "can't find that username"
|
||||||
|
|
|
@ -13,7 +13,7 @@ search_url = api_prefix + "?action=opensearch&search=%s&format=xml"
|
||||||
|
|
||||||
paren_re = re.compile('\s*\(.*\)$')
|
paren_re = re.compile('\s*\(.*\)$')
|
||||||
|
|
||||||
@hook.command(hook='w')
|
@hook.command(hook='w (.*)')
|
||||||
@hook.command
|
@hook.command
|
||||||
def wiki(query):
|
def wiki(query):
|
||||||
print query
|
print query
|
||||||
|
@ -24,6 +24,9 @@ def wiki(query):
|
||||||
ns = '{http://opensearch.org/searchsuggest2}'
|
ns = '{http://opensearch.org/searchsuggest2}'
|
||||||
items = x.findall(ns + 'Section/' + ns + 'Item')
|
items = x.findall(ns + 'Section/' + ns + 'Item')
|
||||||
|
|
||||||
|
if items == []:
|
||||||
|
return 'no results found'
|
||||||
|
|
||||||
def extract(item):
|
def extract(item):
|
||||||
return [item.find(ns + x).text for x in
|
return [item.find(ns + x).text for x in
|
||||||
('Text', 'Description', 'Url')]
|
('Text', 'Description', 'Url')]
|
||||||
|
|
Loading…
Reference in New Issue