Sha256: b4263188207035247cc830df07c10522141a4c38574732dbdb15137ea8a6324e
Contents?: true
Size: 1.49 KB
Versions: 6
Compression:
Stored size: 1.49 KB
Contents
class Scamp module Messages def say(message, room_id_or_name) send_message(room_id_or_name, message, "Textmessage") end def paste(message, room_id_or_name) send_message(room_id_or_name, message, "PasteMessage") 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
6 entries across 6 versions & 1 rubygems