summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaine Virta <rane@kapsi.fi>2009-02-24 19:17:54 +0200
committerRaine Virta <rane@kapsi.fi>2009-02-26 01:09:20 +0200
commit467f4898d84b375962eb09f92978c5411b95f94f (patch)
tree886b2d53ac6e8d54ab78cd60c3ddf04246323dd5
parentd902c4cd6d0a9b359111441f6920eb031833b0ab (diff)
search: add command 'lucky'
Sometimes you just wish to google the first hit and have a clutter free output showing only the url.
-rw-r--r--data/rbot/plugins/search.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/data/rbot/plugins/search.rb b/data/rbot/plugins/search.rb
index a7ac64cb..542f7cba 100644
--- a/data/rbot/plugins/search.rb
+++ b/data/rbot/plugins/search.rb
@@ -96,6 +96,11 @@ class SearchPlugin < Plugin
single ? u : "#{n}. #{Bold}#{t}#{Bold}: #{u}"
}.join(" | ")
+ if params[:lucky]
+ m.reply urls.first
+ return
+ end
+
# If we return a single, full result, change the output to a more compact representation
if single
m.reply "Result for %s: %s -- %s" % [what, results, Utils.get_first_pars(urls, first_pars)], :overlong => :truncate
@@ -110,6 +115,11 @@ class SearchPlugin < Plugin
end
+ def lucky(m, params)
+ params.merge!(:lucky => true)
+ google(m, params)
+ end
+
def gcalc(m, params)
what = params[:words].to_s
searchfor = CGI.escape(what)
@@ -224,6 +234,7 @@ plugin = SearchPlugin.new
plugin.map "search *words", :action => 'google', :threaded => true
plugin.map "google *words", :action => 'google', :threaded => true
+plugin.map "lucky *words", :action => 'lucky', :threaded => true
plugin.map "gcount *words", :action => 'gcount', :threaded => true
plugin.map "gcalc *words", :action => 'gcalc', :threaded => true
plugin.map "gdef *words", :action => 'gdef', :threaded => true