Sha256: 10493a525b7a94e8e16b7682737466a57ed5ec179b3c93d1368d91b9a615fbd5
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
class Scamp module Messages def say(message, room_id_or_name) send_message(room_id_or_name, message, "Textmessage") end def play(sound, room_id_or_name) send_message(room_id_or_name, sound, "SoundMessage") end private # curl -vvv -H 'Content-Type: application/json' -d '{"message":{"body":"Yeeeeeaaaaaahh", "type":"Textmessage"}}' -u API_KEY:X https://37s.campfirenow.com/room/293788/speak.json def send_message(room_id_or_name, payload, type) # post 'speak', :body => {:message => {:body => message, :type => type}}.to_json room_id = room_id(room_id_or_name) url = "https://#{subdomain}.campfirenow.com/room/#{room_id}/speak.json" http = EventMachine::HttpRequest.new(url).post :head => {'Content-Type' => 'application/json', 'authorization' => [api_key, 'X']}, :body => Yajl::Encoder.encode({:message => {:body => payload, :type => type}}) http.errback { logger.error "Couldn't connect to #{url} to post message \"#{payload}\" to room #{room_id}" } http.callback { if [200,201].include? http.response_header.status logger.debug "Posted message \"#{payload}\" to room #{room_id}" else logger.error "Couldn't post message \"#{payload}\" to room #{room_id} using url #{url}, http response from the API was #{http.response_header.status}" end } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
scamp-0.1.2 | lib/scamp/messages.rb |
scamp-0.1.1 | lib/scamp/messages.rb |