Fixed formatting.

This commit is contained in:
Fletcher Boyd 2013-09-04 18:30:04 +08:00
parent 146ae3c279
commit 4069dd21a3
89 changed files with 615 additions and 496 deletions

View file

@ -13,28 +13,28 @@ def api_get(kind, query):
@hook.command('gis')
@hook.command
def googleimage(inp):
"gis <query> -- Returns first Google Image result for <query>."
"""gis <query> -- Returns first Google Image result for <query>."""
parsed = api_get('images', inp)
if not 200 <= parsed['responseStatus'] < 300:
raise IOError('error searching for images: %d: %s' % ( \
parsed['responseStatus'], ''))
raise IOError('error searching for images: %d: %s' % (
parsed['responseStatus'], ''))
if not parsed['responseData']['results']:
return 'no images found'
return random.choice(parsed['responseData']['results'][:10]) \
['unescapedUrl']
['unescapedUrl']
@hook.command('search')
@hook.command('g')
@hook.command
def google(inp):
"google <query> -- Returns first google search result for <query>."
"""google <query> -- Returns first google search result for <query>."""
parsed = api_get('web', inp)
if not 200 <= parsed['responseStatus'] < 300:
raise IOError('error searching for pages: %d: %s' % (
parsed['responseStatus'], ''))
parsed['responseStatus'], ''))
if not parsed['responseData']['results']:
return 'No results found.'