opensoul.org

Tinder: Listening is just as important as speaking

January 27, 2007 code 1 min read

I just released an update to Tinder, the really unofficial Campfire API, that allows listening in on a room:

campfire = Tinder::Campfire.new 'mysubdomain'
campfire.login 'myemail@example.com', 'mypassword'

room = campfire.find_room_by_name 'Room 1'

messages = room.listen
#=> [{:person=>"Brandon", :message=>"I'm getting very sleepy", :user_id=>"148583", :id=>"16434003"}]

\#listen takes an option block, which causes it to poll for new messages every 5 seconds and call the block for each message. It works great for heckling (ok, maybe that’s not the intent):

room.listen do |m|
  room.speak "You're dumb!" if m[:person] == 'Brandon'
end

Check out my original post for more information about Tinder. Feedback and patches are welcome!

Thanks to Jesse Newland for the listening code.

This content is open source. Suggest Improvements.

@bkeepers

avatar of Brandon Keepers I am Brandon Keepers, and I work at GitHub on making Open Source more approachable, effective, and ubiquitous. I tend to think like an engineer, work like an artist, dream like an astronaut, love like a human, and sleep like a baby.