skip main content

Posts Tagged ‘jabber’

BBC Programmes via Instant Messenger

posted by Duncan at 4:04 pm on November 2nd, 2008

I have been playing with ejabberd, Jabber, XMPP and the various client libraries, specifically the rather wonderfully simple Jabber::Simple and Jabber:Bot.

It all started because I was doing a Fireeagle integration job with a product at work, and was getting frustrated with the fact that it is still not super simple to update my location. It struck me as I stared at my desktop, that I always have Adium running. Wouldn’t it be great if I had a Fireeagle contact that I could just tell my location, and it would go off and update, letting me know when they’re done. Now that part is midway done (post to come), but before I started that, I wanted to research more the workings of a Chatterbot, a computer program that pretends to be a human and can answer basic commands. They have been around for a long time, I remember playing with an IRC bot a while back, getting it to display the last commit messages from Subversion.

So that research turned into a BBC Programmes bot. As I worked on BBC Programmes, I have good knowledge of the site and the data within, and building a bot that integrated with that data seemed a good example of using the restful API available.

If you just want to try this thing out, here are the details of what you need to do.

  1. You need a Gmail or Jabber compatible IM account
  2. You need a Jabber enabled client, I’ve listed a few:
  3. You need to add a new contact: im.bbcprogrammes@gmail.com

This should be it. You should have a new contact appear in your list (They have a BBC logo as an avatar). You can now begin a conversation with this contact. It’s probably best to start with:

-> ?
-> help

BBC Programmes IM BotThe help menu is your best starting point

You can get more detailed help on the various commands with:

-> ? upcoming
-> ? schedule

This should give you enough information to start making queries against the BBC Programmes data.

[NOTE] I should say at this point, that this service is running on my own little virtual box, and I don’t have the funds to have Deep Blue, so the service may well fall over, or be a bit flaky if many people use it. I’m hoping to persuade my bosses to let me host this on the BBC infrastructure at some point, but until then be aware. The beauty of this kind of service though is that if it dies, your contact just goes offline. When the service is brought up again, the contact comes online. Nothing too drastic in other words.

So here’s a few fun commands to get you going:

# show what's currently on 6music
-> now 6music
# show what's currently on radio4
-> next radio4:fm
# show the BBC One London schedule
-> schedule bbcone:london
# show the BBC One London schedule in detail
-> schedule bbcone:london in full
# show upcoming programmes in the format Films available on BBC One in detail
# you can get a full formats list from: http://add.url.com 
-> upcoming films on bbcone:london in full
# show upcoming programmes in the genre Drama/Soaps available in detail
# you can get a full genres list from: http://add.url.com 
-> upcoming drama:soaps in full

BBC Programmes IM botUpcoming films on BBC Two

Hopefully you get the idea, and like I said the help page should give you all the information you need, specifically around getting hold of all the network names available to the bot.

I have a few ideas for future development, specifically around asking for things that you can watch via iPlayer. So you could ask:

-> available films on bbcone:london
-> available eastenders

This is in the pipeline, and I’ll just add the functionality as I get it finished, so keep an eye on the help page for more commands.

Much of the heavy carrying is handled but the brilliant Jabber::Bot written by Brett Stimmerman. I’ve customised it slightly for my needs, by added the ability to deamonize it and also tweaks around the displaying of help information.

The work that remained was to build a ‘recipe’ script that defines and handles all the incoming commands. There is currently no caching or optimisations, but you can get a copy of this to use yourself from:

You can just add the relevant configuration entries at the top of the script and then start in a way that suits you best. I have moved over to using daemontools, but you can still uncomment the relevant lines in the script (see comments) and use:

-> ./bbcbot start

and bingo, you should now have your own BBC Programmes bot to communicate with.

Twammer, sending stuff from Twitter to Yammer

posted by Duncan at 8:12 pm on September 28th, 2008

I use Twitter. I don’t really post much, but I do like to dip in and hear what my friends are doing. Yammer is like a private Twitter for companies. We have just had a network set up for the BBC, which is interesting. Again, I like the idea of posting what I am doing and dipping into what other people are doing around the organisation.

So you can see my problem, I’m doubling up here a bit. When I post something to Twitter, and I think it would be relevant for work too, I don’t want to have to open a different interface and post it again. Now there are services like ping.fm which will sync every site you belong to, but I what to decide what gets posted at work and what doesn’t in this instance. The simple answer is to build something that looks at my Twitter feed and if it sees anything new, then posts it off to Yammer. My friend Mr Humfrey does that very thing. I wanted more than this though, I wanted to filter, plus I wanted to make it easy to use, so I have written this very simple app that does the job:

  1. Read my Twitter feed every n minutes for changes
  2. Keep messages with my chosen keyword
  3. Remove keyword, and send off to Yammer

Twammer usage:

# Display help
./twammer -h
 
# check Twitter messages with last 5 mins (default)
# filter by #bbc but don't send anything to Yammer
./twammer -t 47983 -u user -p pass -f bbc -q
 
# check Twitter messages within last 10 mins
# send anything to Yammer. Show output
./twammer -t 47983 -u user -p pass -d 10 -v

This is designed to be run as a cron job. You must also make sure you run it at the same interval as the –delay in the app. Here’s what my crontab looks like:

0,5,10,15,20,25,30,35,40,45,50,55 * * * * /home/duncan/bin/twammer -t 47983 -u user -p pass -f bbc > /dev/null

[UPDATE] Changed to using the correct API instead of scraping the RSS


back to the top