summaryrefslogtreecommitdiffstats
path: root/modules/search.py
diff options
context:
space:
mode:
authorSean B. Palmer <http://inamidst.com/sbp/>2008-02-23 12:16:43 +0000
committerSean B. Palmer <http://inamidst.com/sbp/>2008-02-23 12:16:43 +0000
commit2fb00589439a4efb3906d4e681e7ed815dcd180a (patch)
tree0a6b0ff1a4b5697fc7c3cb0aa3dc934246fcb874 /modules/search.py
parent7931fab14599b739c18c8f1ebcc24b75688dbc09 (diff)
downloadbot-2fb00589439a4efb3906d4e681e7ed815dcd180a.tar.gz
bot-2fb00589439a4efb3906d4e681e7ed815dcd180a.tar.bz2
bot-2fb00589439a4efb3906d4e681e7ed815dcd180a.zip
Lots of fixes, changes, and new goodies.
Diffstat (limited to 'modules/search.py')
-rwxr-xr-xmodules/search.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/modules/search.py b/modules/search.py
index 9ad1a04..06241d4 100755
--- a/modules/search.py
+++ b/modules/search.py
@@ -30,10 +30,14 @@ def search(query, n=1):
def result(query):
results = search(query)
- return results['results'][0]['url']
+ if results['results']:
+ return results['results'][0]['url']
+ return None
def count(query):
results = search(query)
+ if not results['results']:
+ return '0'
return results['estimatedCount']
def formatnumber(n):
@@ -44,8 +48,11 @@ def formatnumber(n):
return ''.join(parts)
def g(phenny, input):
- uri = result(input.group(2))
- phenny.reply(uri)
+ query = input.group(2)
+ uri = result(query)
+ if uri:
+ phenny.reply(uri)
+ else: phenny.reply("No results found for '%s'." % query)
g.commands = ['g']
g.priority = 'high'
@@ -60,7 +67,7 @@ r_query = re.compile(
r'\+?"[^"\\]*(?:\\.[^"\\]*)*"|\[[^]\\]*(?:\\.[^]\\]*)*\]|\S+'
)
-def compare(phenny, input):
+def gcs(phenny, input):
queries = r_query.findall(input.group(2))
if len(queries) > 6:
return phenny.reply('Sorry, can only compare up to six things.')
@@ -76,7 +83,7 @@ def compare(phenny, input):
results = [(term, n) for (n, term) in reversed(sorted(results))]
reply = ', '.join('%s (%s)' % (t, formatnumber(n)) for (t, n) in results)
phenny.say(reply)
-compare.commands = ['gco', 'comp']
+gcs.commands = ['gcs']
if __name__ == '__main__':
print __doc__.strip()