archive my tweets

I liked vrypan’s idea about keeping control of your tweets.
But I wanted to do it «the other way around».
Keep using the twitter interface, but archive a copy of my tweets in a dedicated wordpress blog.

So I found a wordpress plugin that does that:
Twitter Tools

I also wanted to populate my blog with my older tweets.
So a bit of Net::Twitter::Lite and WordPress::API thrown in a few lines of perl code, did the trick!


#!/usr/bin/perl
use Net::Twitter::Lite;
use WordPress::API;
use Unicode::String;
use utf8;

my $nt = Net::Twitter::Lite->new(
 username => "twitter-username", password => "twitter-password");
my $w = WordPress::API->new({ proxy => 'http://stsimb-tweets.irc.gr/xmlrpc.php',
 username => 'blog-username', password => 'blog-password', });

eval {
 my $statuses = $nt->user_timeline({ count => 100, page => '1' });
 for my $status ( @$statuses ) {
   print "$status->{id} $status->{created_at} $status->{text}\n";
   my $tweet = Unicode::String::utf8($status->{text});
   my $post = $w->post;
   $post->description("$tweet");
   $post->dateCreated("$status->{created_at}");
   $post->save;
 }
};
warn "$@\n" if $@;

So now I have most of my tweets at http://stsimb-tweets.irc.gr/.
It’s my own tweetbackup service :-)

Advertisement

Send mon alerts to twitter

Just a quick proof of concept hack..

I modified twitter-cmdline script to fit mon‘s alert specs..

Download twitter-cmdline-1.03 and place it in /usr/lib/mon/alert.d (or appropriate path of your mon installation).

Then grab twitter.alert and put it there too.

Run twitter.pl and give your twitter credentials (stored in ~/.twitterrc the first time it runs). It’s probably a good idea to create an extra twitter account for this.

Now use twitter.alert in your mon config to send alerts in twitter, where people can follow them!

watch system01
    service disk_root
        interval 5m
        monitor munin.monitor -M df -F _dev_cciss_c0d0p1 -w 90 -c 95 -H
        depend SELF:ping
        period _ANYTIME_
            alertevery 15m summary
            comp_alerts
            alertafter 3
            alert twitter.alert
            upalert twitter.alert