def speak(room, message)
room_id = find_room_id_by_name(room)
raise "No such room: #{room}." unless room_id
url = URI.parse("#{base_url}/room/#{room_id}/speak.json")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true if @options[:ssl]
req = Net::HTTP::Post.new(url.path)
req.basic_auth(@options[:token], 'X')
req.set_content_type('application/json')
req.body = { 'message' => { 'body' => message } }.to_json
res = http.request(req)
case res
when Net::HTTPSuccess
true
else
raise res.error!
end
end