Sha256: 9f76c85fda61439d5d4aa20728ce98603de7ec4565f758c4f92530f0fe92a4a0
Contents?: true
Size: 730 Bytes
Versions: 2
Compression:
Stored size: 730 Bytes
Contents
module Muzang module Plugins class Google include Muzang::Plugins::Helpers def initialize(bot) @bot = bot end def call(connection, message) on_channel(message) do message.message.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(message.channel, "#{result["url"]} | #{result["titleNoFormatting"]}") } end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
muzang-plugins-1.1.6 | lib/muzang-plugins/muzang-google.rb |
muzang-plugins-1.1.5 | lib/muzang-plugins/muzang-google.rb |