All pastes #29654 Raw Edit

Cheez

public text v1 · immutable
#29654 ·published 2005-11-20 17:17 UTC
rendered paste body
use strict;
use vars qw($VERSION %IRSSI);
use Irssi;

$VERSION = "0.0.1";
%IRSSI = (
          authors     => "Chris \'Cheez\' Stretton",
          contact     => "cstretton\@gmail.com",
          name        => "Winamp",
          licence     => "Public Domain",
          description => "Prints currently playing winamp song in active channel",
          changed     => "Wed Jun  2 17:00:00 CET 2002",
          changes     => "script created"
    );

# path to winamp song name
my $songfile = "$ENV{HOME}/www/sig/winamp.txt";

sub cmd_mp3 {
    my $witem = Irssi::active_win()->{active};
    if (!open(WINAMP, '<', $songfile)) {
        Irssi::print('mp3: Song file not found...');
    } else {
        my @lines = <WINAMP>;
        if (@lines[0] eq "No song currently playing.") {
            Irssi::print('mp3: '.@lines[0]);
        } else {
            if ($witem && ($witem->{type} eq "CHANNEL" || $witem->{type} eq "QUERY")) {
                $witem->command("ACTION ".$witem->{name}." bops to ".@lines[0]);
            } else {
                Irssi::print('mp3: You must do this in a channel or query window.');
            }
        }
        close WINAMP;
    }
}

Irssi::command_bind('mp3', 'cmd_mp3');