Sha256: 17d5bfa0d7c38387ee28917ed2e48092f3bffea25a00563e8a0f2f0deb24dc2e

Contents?: true

Size: 625 Bytes

Versions: 1

Compression:

Stored size: 625 Bytes

Contents

module Ellen
  module Handlers
    class GoogleImage < Base
      on /image( me)? (.+)/, name: "image", description: "Search image from Google"

      on /animate( me)? (.+)/, name: "animate", description: "Search animation from Google"

      def image(message)
        if url = search(message[2])
          robot.say url
        end
      end

      def animate(message)
        if url = search(message[2], animated: true)
          robot.say url
        end
      end

      private

      def search(query, options = {})
        Ellen::GoogleImage::Client.new(options.merge(query: query)).get
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ellen-google_image-0.0.4 lib/ellen/handlers/google_image.rb