Skip to content

Instantly share code, notes, and snippets.

@julienXX
Created December 19, 2012 14:23
Show Gist options
  • Save julienXX/4336994 to your computer and use it in GitHub Desktop.
Save julienXX/4336994 to your computer and use it in GitHub Desktop.
require "uri"
require "yajl/http_stream"
require "terminal-notifier"
require "celluloid"
class Stream
include Celluloid
def initialize(room, token)
@room = room
@token = token
start!
end
def start
regexp = Regexp.new('julien', true)
Yajl::HttpStream.get(self.url) do |message|
puts message.inspect
if message['body'] && message['body'].match(regexp)
TerminalNotifier.notify(message['body'], :title => 'Campfire')
end
end
end
def url
@url = URI.parse("http://#{@token}:x@streaming.campfirenow.com/room/#{@room}/live.json")
end
end
token = TOKEN
room_ids = [1,2]
room_ids.each do |room_id|
puts "- Listening room #{room_id}"
stream = Stream.new(room_id, token)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment