Skip to content

Instantly share code, notes, and snippets.

@cronin101
Created April 11, 2015 22:49
Show Gist options
  • Save cronin101/85708f735c6f97581017 to your computer and use it in GitHub Desktop.
Save cronin101/85708f735c6f97581017 to your computer and use it in GitHub Desktop.
/r/thebutton Naration
require 'faye/websocket'
require 'eventmachine'
require 'json'
EM.run do
ws = Faye::WebSocket::Client.new('wss://wss.redditmedia.com/thebutton?h=e71fa51d78d282393f403bdbd5d38ca6a69a9618&e=1428873519')
last_time = 60
ws.on :message do |event|
data = JSON.parse event.data
time = data["payload"]["seconds_left"].to_i
if last_time <= time
`say "some scrub reset"`
else
`say "#{time}"`
end
last_time = time
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment