scribot fodder

Randy J. Ray rjray at blackperl.com
Fri Sep 21 23:07:37 BST 2007


I have a (reasonably stable) Twitter-bot up and running. Like the existing 
"cpan" Twitter, it spools CPAN uploads to Twitter from the RDF that 
www.cpan.org publishes. Unlike "cpan" (which was apparently shut-off a little 
over a month ago anyway), it provides links: The released package itself is 
linked, and behind the scenes the MANIFEST file is scanned for something 
matching /(changes|changelog|changelist)\b/i and if found is also linked. If no 
change-file is found, README is linked to instead (unless there's no README, in 
which case you just get the one link instead of two).

The bot polls the RDF URL every 15min or so, using an If-Modified-Since header. 
Any new CPAN uploads are queued up for posting to Twitter, spaced out evenly 
over the 15min waiting period (i.e., if there are two new CPAN uploads then 
tweet fires immediately and the second waits roughly 7.5 minutes to fire... 
fifteen new uploads would fire at roughly one-minute intervals) so that it 
doesn't suddenly spam your Twitter client.

This is still largely alpha, though the code itself is reasonably clean (one 
must love being borderline-OCD). I want to add better local logging, reading of 
direct messages to interpret them as commands, stats tracking, etc. to it yet. 
Also, I plan to abstract the overall architecture moreso than it currently is, 
and CPAN that as a Twitterbot sort of class/mini-framework. For that matter, 
the structure of the message that gets sent as a tweet is itself vulnerable to 
change yet, as I'm not 100% happy with it (but as far as I know, I can't use 
HTML for formatting, so I can't (for example) link the module name to the CPAN 
page, I can only send the URL in the message body and rely on clients like IM 
or Twitterific to hot-link the text).

For now, though, you can get your CPAN addiction fed via Twitter at:

	http://twitter.com/cpan_linked

Randy
(I'm also thinking about changing the name to "cpan_with_links". Alternately, 
if the current owner of the "cpan" Twitter account wants to talk, feel free to 
e-mail me!)
-- 
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Randy J. Ray      Sunnyvale, CA      http://www.rjray.org   rjray at blackperl.com

Silicon Valley Scale Modelers: http://www.svsm.org


More information about the london.pm mailing list