Saturday, August 18, 2007

publish-bot with logging capability

Last year sometime, I received several emails from people wanting me to release the supybot IRC plugins I wrote back in 2005 for svn and RSS updates. I'd actually written for several different IRC bots (both twisted-based, and non-twisted bots) but the code was particularly messy for supybot. During one conversation, I said that I'd really done it all wrong, and the last thing I wanted to do was clean up wrong code. If I got a chance, I would do it right:
  • create an IRC client for communicating to servers+channels
  • create a message server running on local host
  • process/parse data from the local server to the IRC client (i.e., appropriate IRC channel)
Such a flexible design would suit every need I have for writing data to an IRC channel.

Turns out radix did just so earlier this year for Canonical, as he relates in this blog post. This is exactly what I needed this weekend while migrating my old IRC bot to a new server. Well, almost all I needed. There were a couple features I wanted to add...

Not having worked with bzr or launchpad much, I asked radix about branching his code, since I heard that Canonical actually provides developers a way of doing that without leaving the launchpad environment of trunk. His instructions were quite simple, and I summarize them here for the benefit of others:
  • find the project you want to branch on launchpad
  • checkout trunk (if that's what you're branching)
  • commit (a local action) with a message about this being a new branch
  • make your changes (with any number of commits)
  • push all your commits to your branch on launchpad
The steps above assume that you have bzr installed and have uploaded your SSH keys to launchpad.

Here are the bzr commands that I used:
bzr branch publish-logger-bot
cd publish-logger-bot
bzr commit --unchanged -m "Created branch of radix's publish-bot."
bzr push s
The changes I committed:
  • enabled logging
  • added log-rotation
  • added an HTTP service for browsing the log files
The code is available here:

Forthcoming features:
  • a search form for the log files
  • a parser for bot commands, thus enabling human -> bot communications (will probably dust off my old pyparsing code for this)
  • arbitrary time log rotation (currently it's by day, ad midnight)

And for dessert:
[18-Aug-2007 17:56:50] [connected at Sat Aug 18 17:56:50 2007]
[18-Aug-2007 17:57:00] [wallflower (logger bot) has joined #supersecretchannel]
[18-Aug-2007 18:00:38] <keturn> what's a wallflower?
[18-Aug-2007 18:20:09] <PenguinOfDoom> It's a flower that grows out of a wall
[18-Aug-2007 18:20:52] <keturn> and has an irc client?
[18-Aug-2007 18:22:49] <keturn> is it related to an oubiwann?
[18-Aug-2007 18:34:00] <exarkun> I reckon it is

Technorati Tags: , , , , , ,


  1. I wrote a fairly extensible bot framework for some things we need at OSAF.

    Currently I have trac support, a bugzilla bugbash feature, jabber support, a channel aware pastebin, and tinyurl in the base plugins.

    bear is working on porting all of our old soupy based bot functionality to the new bot.

    I have yet to document it as bear and me are the only ones using it, but if anyone shows interest I could spend some time documenting it up.

  2. I just wanted to make one point: The "commit --unchanged" you made really has no point. When you do commits to the branch they will be marked with the branch, so there's no reason to make some special marker commit.

    Thanks for basing your work on publish-bot! I'll review it and merge it to trunk if it's good.

  3. Chris: regarding the "commit --unchanged", I did that simply to make a notation in my branch, solely for the sake of readability.

    As for merging, that would be cool. But I'd wait until I've put in place more general/flexible time-based rotation.

    mikeal: thanks for the heads up! I'll check it out (btw, is that bear of twisted.divmod?)

  4. 5 years later, it's resurrected! Updated to run with the latest Twisted, and using it for the OpenStack Developer Summit: