Is this your first visit? You may want to subscribe to the feed.

Tinder: Listening is just as important as speaking

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.

Code: 37signals, api, campfire, gem, ruby, tinder Jan 27, 2007 ● updated Jan 27, 2007 12 comments

12 comments

  1. Excellent work Brandon! Our Campfire Bot, which we’ve lovingly named Elsington, is quite a good heckler. I’m interested to see what else comes of this.

    Jesse Newland Jesse Newland January 27, 2007 at 08:50 AM
  2. Having no luck with listen…

    room.listen do |m| room.speak “Test” end

    ...nothing happens.

    Adam Roth Adam Roth February 22, 2007 at 02:16 PM
  3. Adam,

    Hmm, I wonder if 37s deployed something that change how the polling works.

    I’m not going to have time to look into it for a while, but patches are appreciated.

    Brandon Brandon February 22, 2007 at 03:44 PM
  4. Brandon & Adam,

    37signals indeed did change something. I spoke to DHH a few minutes ago and he said they deployed a new build of campfire recently. My bot was working fine up until two days ago when they must have made the change.

    Josh Owens Josh Owens February 23, 2007 at 04:22 PM
  5. Huzzah!

    I found the issue and I have emailed Brandon about it. I also found some other interesting stuff while digging around in the code.

    I added a ping command in my version of tinder, that way if you set the bot to listen, he will ping every 60 seconds to stay logged in.

    Josh Owens Josh Owens February 23, 2007 at 08:54 PM
  6. Josh,

    I modified line 121 of room.rb (0.1.3 via gems) so it returns the person name for enter/leave messages too, so now my bot can personally respond to anyone joining the room (or insult them for leaving).

    :person => msg.gsub(/<(\/)?span>/, '').scan(/<td class=\\"person\\">([^<]+)<\/td>/).to_s

    Tim.

    Tim Blair Tim Blair March 09, 2007 at 09:22 AM
  7. Josh,

    Did you figure out what has changed in the campfire API to break the marshmallow ‘watch’ command? I’d like to fix our scripts :)

    Thanks, Tammer

    Tammer Saleh Tammer Saleh April 08, 2007 at 07:03 PM
  8. Here’s a patch against 0.1.4 that keeps Tinder alive for longer than a couple minutes:

    http://pastie.caboo.se/129632

    Jesse Newland Jesse Newland December 17, 2007 at 11:51 AM
  9. Jesse,

    Thanks for the patch. This was actually fixed in svn a few weeks ago, I just haven’t released a new version of the gem. Check it out and let me know how it works for you.

    Brandon Brandon December 17, 2007 at 11:56 AM
  10. I’m stumped on this one: I just added tinder as a publisher to cerberus and I want to be a good little programmer and include a functional test. How do I create a mock for Tinder?

    Ken Mayer Ken Mayer December 20, 2007 at 11:42 PM
  11. It’d be good if Tinder supported http authenticating proxies – one of the big benefits of campfire is that it works from inside corporate firewalls, but Tinder doesn’t handle this without modifications.

    Korny Korny March 30, 2008 at 11:20 PM
  12. We just deployed chat using this wonderful API on madmimi.com Thank you, thank you! It rocks.

    Gary Levitt Gary Levitt April 25, 2008 at 12:16 PM
  13. Brandon, This is a lot of fun to play with, and was incredibly easy to get working, but my Ruby isn’t up to par. I’ve begun work on what is effectively a Java port of your approach and put it on Google Code

    My grandiose idea is that with a robust-enough Campfire client, and some more tinkering, one might “proxy translate” Campfire API calls into another chat protocol, like Jabber or IRC. The proxy might accept say, IRC connections, and open up a a connection to Campfire with some API and translate back and forth. This way jabber or IRC clients might connect to Campfire rooms. I think this would be useful for say, integrating Campfire into Adium, or running any number of IRC bots.

    Anyways thanks for the great software, and cheers!

    Alan Alan September 23, 2008 at 04:50 AM

Speak your mind:

*

*


* I hate spam and will never sell or publish your email address.

(You may use textile in your comments.)

Subscribe

Browse by Tag