pitrix/src/tools/list_effects.rb

27 lines
426 B
Ruby
Executable File

#!/usr/bin/env ruby
require 'websocket-eventmachine-client'
require 'json'
IP = ARGV[0] or raise "No IP given"
uri = "ws://#{IP}:80/ws"
EM.run do
ws = WebSocket::EventMachine::Client.connect(uri: uri)
ws.onopen do
ws.send "effects?"
end
ws.onmessage do |msg, type|
if type==:text
j = JSON.parse(msg)
if j["effects"]
j["effects"].each do |effect|
puts effect
end
exit
end
end
end
end