6 class GooglePlugin < Plugin
7 def help(plugin, topic="")
8 "search <string> => search google for <string>"
11 unless(m.params && m.params.length > 0)
12 m.reply "incorrect usage: " + help(m.plugin)
15 searchfor = URI.escape m.params
17 query = "/search?q=#{searchfor}&btnI=I%27m%20feeling%20lucky"
24 if(ENV['http_proxy'] =~ /^http:\/\/(.+):(\d+)$/)
30 http = @bot.httputil.get_proxy(URI.parse("http://www.google.com"))
34 resp = http.get(query)
36 result = resp['location']
41 if e.response && e.response['location']
42 result = e.response['location']
47 m.reply "#{m.params}: #{result}"
50 plugin = GooglePlugin.new
51 plugin.register("search")