summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/rbot/plugins/search.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/data/rbot/plugins/search.rb b/data/rbot/plugins/search.rb
index c44100b1..fd1aefdc 100644
--- a/data/rbot/plugins/search.rb
+++ b/data/rbot/plugins/search.rb
@@ -21,11 +21,15 @@ class SearchPlugin < Plugin
def google(m, params)
what = params[:words].to_s
searchfor = URI.escape what
+ # This method is also called by other methods to restrict searching to some sites
if params[:site]
site = "site:#{params[:site]}+"
else
site = ""
end
+ # It is also possible to choose a filter to remove constant parts from the titles
+ # e.g.: "Wikipedia, the free encyclopedia" when doing Wikipedia searches
+ filter = params[:filter] || ""
url = "http://www.google.com/wml/search?q=#{site}#{searchfor}"
@@ -42,7 +46,10 @@ class SearchPlugin < Plugin
return
end
results = results[0...3].map { |res|
- "#{res[0]}. #{Bold}#{Utils.decode_html_entities res[2].strip}#{Bold}: #{URI.unescape res[1].strip}"
+ n = res[0]
+ t = Utils.decode_html_entities res[2].gsub(filter, '').strip
+ u = URI.unescape res[1]
+ "#{n}. #{Bold}#{t}#{Bold}: #{u}"
}.join(" | ")
m.reply "Results for #{what}: #{results}"
@@ -52,6 +59,7 @@ class SearchPlugin < Plugin
lang = params[:lang]
site = "#{lang.nil? ? '' : lang + '.'}wikipedia.org"
params[:site] = site
+ params[:filter] = / - Wikipedia.*$/
return google(m, params)
end
end