Sha256: 358be69b860f75b77d1a492d4d48f5d550fa3f87edcac6e0836aea5f65ba93b9
Contents?: true
Size: 780 Bytes
Versions: 2
Compression:
Stored size: 780 Bytes
Contents
module API module Giphy WS_URL = "http://api.giphy.com/v1/gifs/search" URI_REGEX = /spotify:([a-z]+):(\w+)/ def search(query) puts "dans le seeeeaaartch !!!" query = query.gsub('!gsearch', '').strip # Check that parameters are correct or return the corresponding error return "Please provide something to search" if query.nil? || query == "" # Perform the search and return the result result = "" response = HTTParty.get("#{WS_URL}?q=#{URI.encode(query)}&api_key=#{@@api_key}") if response['data'] && response['data'].count > 0 gif = response['data'].first result = "Check this : #{gif['url']}" else result = 'Nothing found with that parameter.' end result end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hibot-0.0.4 | lib/api/giphy.rb |
hibot-0.0.2 | lib/api/giphy.rb |