From 467f4898d84b375962eb09f92978c5411b95f94f Mon Sep 17 00:00:00 2001 From: Raine Virta Date: Tue, 24 Feb 2009 19:17:54 +0200 Subject: [PATCH] search: add command 'lucky' Sometimes you just wish to google the first hit and have a clutter free output showing only the url. --- data/rbot/plugins/search.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 -- 2.39.2