[Buildbot-devel] IM status clients, extending the IRC bot

Brian Warner warner-buildbot at lothar.com
Thu Dec 20 21:20:27 UTC 2007


On Wed, 5 Dec 2007 14:07:14 +0000
"Neil Hemingway" <neil.hemingway at googlemail.com> wrote:

> I'd also like to extend the IRC bot to do something similar to (but
> not exactly the same as) what #75 discusses.  Has the work on this
> got started, because if not, I'm happy to begin it.  That being said,
> I'd appreciate a few pointers on how you saw the code develop to
> achieve the objective.


Awesome. I believe the refactoring I described in that ticket is already in
trunk.. take a look at buildbot/status/words.py . There's a base class named
Contact, of which there's supposed to be one per active user (created
on-demand). It has the basic command+response code. Then each connection
protocol (IRC, AIM, etc) gets a subclass of Contact, which fills in the
protocol-specific methods to actually send and receive messages. IRCContact
already exists. The IrcStatusBot class is the "channel", and handles the IRC
connection as a whole: it has methods from the IChannel interface to create
and delete contacts.

So the plan is to make a new subclass like AIMContact or JabberContact, make
a new IChannel-implementing class for AIM or Jabber (which holds the
buildbot's end of the connection), then a new factory to initiate the
connection and log in and create the channel.

I got some distance into making an AIM channel, but got stuck trying to
figure out Twisted's somewhat-confused support of AIM (and also the
differences between TOC and OSCAR, etc). There are a bunch of people doing
Jabber+Twisted right now, so I suspect that effort would be easier.

Once that framework is in place, I want to add some new features:

 * having a per-user Channel gives us a place to set up subscriptions: I
   message the buildbot and tell it I want to hear about new builds; the
   Contact instance reaches out to the Status object and subscribes itself to
   hear about new builds; each time a build finishes it sends me a note. When
   the Contact is deleted (i.e. when I log out of AIM), it needs to
   unsubscribe itself from the BuilderStatuses.

 * A higher-level "I need to notify a user about something" piece of code can
   discover the Contact and use it to send
   build-has-failed-and-it's-your-fault messages, independent of the user
   asking for those messages. My long-term goal is for there to be a
   UserManager object inside the buildbot, and then a Problem-tracking status
   plugin can do usermanager.sendMessageTo(user, "text"), and the UM can try
   several different pathways in sequence: send IM, if it looks like the user
   is idle or logged out then send a message to an IRC channel, if the user
   doesn't respond or hasn't been seen for a while, send email. The UM needs
   to handle "users" with some sort of identifier that can be mapped to IM
   handles, IRC nicknames, or email addresses, and each of the status
   protocol handlers will have to be involved in this mapping.

And I think there are a bunch of other things we can do once we've got a
per-user Contact object as a place to hang the subscriptions too.


cheers,
 -Brian




More information about the devel mailing list