2008-09-13 Adium, Twitter, and Identica

My current setup:

  1. Send my current status to the Identica bot using Adium. I have Adium configured to run an Applescript whenever I do that.
  2. The script waits a few seconds and determines the current status by checking the Identica RSS feed.
  3. Then the script posts the status to Twitter using the Twitter API.
  4. Then the script tells the Adium application to use the status.

Applescript for Mac OS 10.4 Adium 1.3.1:

delay 5
set myStatus to do shell script "~/bin/identica --nick kensanata"
do shell script "~/bin/twitter " & quoted form of myStatus
tell application "Adium"
	repeat with theAccount in accounts
		go online theAccount with message myStatus
	end repeat
end tell

The script that fetches my current status:

use XML::RSS;
use LWP::UserAgent;
use Getopt::Long;

my $verbose = undef;

sub get_feed {
  my $url = shift;
  my $ua = LWP::UserAgent->new;
  my $response = $ua->get($url);
  print $response->code, ' ', $response->message, "\n" if $verbose;
  return $response->content if $response->is_success;
  die $response->code, ' ', $response->message, "\n";

sub get_status {
  my $url = shift;
  my $rss = new XML::RSS;
  my $string = get_feed($url);
  print $string if $verbose;
  return $rss->{items}->[0]->{title};

sub main {
  my $nick = '';
  GetOptions('nick=s' => \$nick,
	     'verbose' => \$verbose);
  my $url = "http://identi.ca/$nick/rss";
  warn "No nick specified.\n" unless $nick;
  binmode STDOUT, ':utf8'; # I assume?
  my $status = get_status($url) . "\n";
  $status =~ s/^$nick: //;
  print $status;


The twitter status posting script:

if test -z "$*"; then
    echo "Status is missing" 1>&2
    exit 1;
CODE=`curl --silent --output /dev/null --write "%{http_code}" \
    --user kensanata@gmail.com:mypassword --data status="$*" \
if test "$CODE" != "200"; then
    echo "$CODE: Posting failed" 1>&2
    exit 1;



Please make sure you contribute only your own work, or work licensed under the GNU Free Documentation License. Note: in order to facilitate peer review and fight vandalism, we will store your IP number for a number of days. See Privacy Policy for more information. See Info for text formatting rules. You can edit the comment page if you need to fix typos. You can subscribe to new comments by email without leaving a comment.

To save this page you must answer this question:

Please say HELLO.