rtyler

Twitterbot. No Really, I Need To Be Stopped

Ok, Twitterer almost had a valid excuse, but this is just bloody unnecessary. I wrote a C# (Mono) news bot for twitter last night out of boreom while waiting for a client to finish writing the webservices needed for my project. The Twitterbot is based very loosely on Mario Menti's perl source code, in that I took the tinyurl idea (and that's about it). I wrote the bot with the concept in mind of using one bot to manage all the feeds at once, which does have a slightly undesirable affect of posting the updates for all the feeds at once, but with a bit of tweaking that can be lessened.

The bot is used to run the following twitter-things: googlenews, googlenewsworld, googlenewssports, googlenewsus, googlenewsent



the technical details


The Twitterbot makes use of RSS.NET for all its incoming feed parsing, but uses the standard System.Net.WebRequest class for posting to both twitter and retrieving the proper tinyurl link. The basic structure of the bot is simple, whenever it grabs new items it'll check that feed's last (stored internally) items to prevent duplication of twitter-posts, and then will shorten the title, generate the tinyurl link and finally post the tiny message to twitter. One of the issues I discovered with Google News is that they randomize the story providers for any given story, i.e. a they might push out a story to their feeds about China's shooting down of a satellite but each time the bot updates that feed may return a different title for the story from a different news organization. In order to prevent flooding, the bot currently has a twitter-posting maximum of two per iteration, which combined with the update interval (30 minutes) helps cut down on both duplicate stories, but also spamming the living hell out of twitter.

The file format that the bot reads feeds and twitter information from is also simple:
<feeds>
<!-- & -> &amp; -->
<feed name="Google News" url="http://news.google.com/news?ned=us&amp;topic=h&amp;output=rss" twitter="user" password="pass"/>
</feeds>


I think I am going to release this as open source in the very near future but I want to check with the twitter guys first to take any steps necessary to prevent spamming their goofy little service. I really think my bot would help organizations use twitter as a minimalistic content delivery platform (market-speak!) if they already spit out content in standard RSS formats elsewhere, but I don't want to step on any toes.

A nice and neat little Twitterbot, all in less than 300 lines of code :)