Class: Muzang::Plugins::Google
- Inherits:
-
Object
- Object
- Muzang::Plugins::Google
- Includes:
- Helpers
- Defined in:
- lib/muzang-plugins/muzang-google.rb
Instance Method Summary collapse
- #call(connection, message) ⇒ Object
-
#initialize(bot) ⇒ Google
constructor
A new instance of Google.
Methods included from Helpers
#create_database, #match, #on_channel, #on_join
Constructor Details
#initialize(bot) ⇒ Google
Returns a new instance of Google.
6 7 8 |
# File 'lib/muzang-plugins/muzang-google.rb', line 6 def initialize(bot) @bot = bot end |
Instance Method Details
#call(connection, message) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/muzang-plugins/muzang-google.rb', line 10 def call(connection, ) on_channel() do ..match(/^(!|@)google (.*?)$/) do |m| http = EventMachine::HttpRequest.new("http://ajax.googleapis.com/ajax/services/search/web").get :query => { :v => "1.0", :q => m[2] } http.callback { results = JSON.parse(http.response) result = results["responseData"]["results"].first connection.msg(.channel, "#{result["url"]} | #{result["titleNoFormatting"]}") } end end end |