Sha256: f3fde9f075eaa36e66b6fe06a422237af6a66fcf703add55b47b2325a62da613

Contents?: true

Size: 483 Bytes

Versions: 3

Compression:

Stored size: 483 Bytes

Contents

require 'google-search'

# Responds with the first google image search result matching a query.
class Robut::Plugin::GoogleImages
  include Robut::Plugin

  desc "image <query> - responds with the first image from a Google Images search for <query>"
  match /^image (.*)/, :sent_to_me => true do |query|
    image = Google::Search::Image.new(:query => query, :safe => :active).first

    if image
      reply image.uri
    else
      reply "Couldn't find an image"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sclemmer-robut-0.6.3 lib/robut/plugin/google_images.rb
sclemmer-robut-0.6.2 lib/robut/plugin/google_images.rb
sclemmer-robut-0.6.1 lib/robut/plugin/google_images.rb