Bookmark and Share BitCoin Donate: 13t8gAWVpHP2ddxMp88d1NFpZjnFJC6UwK
This little irssi script runs every 30 seconds and checks a text file/program for 
a new song/quote/status message. Doesn't really matter what the content is, I personally
use to keep my google talk status set to the song i'm currently listening to.

Save this bugger in ~/.irssi/scripts
Load with /script load gtalk-nowplaying.pl
Execute with /mynp

#!/usr/bin/perl # To load, in irssi type '/script load gtalk-nowplaying.pl' (make sure it's saved as a.pl file).
# When connected to a server type '/cmds' and you'll have a list of available commands.
# Make sure this script is in '~/.irssi/script' folder or else irssi won't know where it is.
# created by ashr
use strict;
use Irssi;
my ($autoaway_sec, $autoaway_to_tag, $am_away, $previousaway);
sub mynp
{
        $previousaway = "";
        reset_timer();
}

sub auto_timeout {
  my ($data, $server) = @_;
  my $h = `cat /mnt/dst06547/nowplaying.txt`;
  my $msg = "Changing nowplaying to $h";

   #Irssi::timeout_remove($autoaway_to_tag);
   #$autoaway_to_tag=undef;

        if (!($previousaway eq $h))
        {
           $previousaway = $h;
           Irssi::print($msg);

           my (@servers) = Irssi::servers();
           $servers[0]->command("/AWAY Busy - $h");

           #my $db = `/usr/bin/mono /home/ashr/scripts/savenp.exe \"$h\"`;
           #Irssi::print($db);
        }
        else
        {
#       Irssi::print("Song still the same, not changing");
        }
}

sub reset_timer {
#     if (defined($autoaway_to_tag)) {
#       Irssi::timeout_remove($autoaway_to_tag);
#       $autoaway_to_tag = undef;
#     }
#     if ($autoaway_sec) {
       #$autoaway_to_tag = Irssi::timeout_add($autoaway_sec*1000,"auto_timeout", "");
       $autoaway_to_tag = Irssi::timeout_add(30000,"auto_timeout", "");
#     }
}

sub not_connected { Irssi::print "Try again when connected to server."; }
sub no_nick { Irssi::print "Nick not given.."; }
sub commands { Irssi::print "/mynp"; }
Irssi::command_bind('mynp', 'mynp');