All pastes #1231 Raw Edit

Anonymous

public text v1 · immutable
#1231 ·published 2004-10-03 06:03 UTC
rendered paste body
use strict;
use vars qw($VERSION %IRSSI);

use Irssi qw(command_bind signal_add);
$VERSION = "0.1";
%IRSSI = (
    authors     => 'Ty Scicluna',
    contact     => 'ak@ak.net.au',
    name        => 'MP3Script',
    description => 'Automatically pulls information from an sql database and displays it in the current window for all to
 see',
    license     => 'Public Domain',
    url         => 'http://not.available.yet/',
    changed     => ''
);

# MP3 Display Script
# for irssi 0.8.1 by Ty Scicluna

my $msghead='^Bautoident^B:';

Irssi::theme_register([
    'mp3script_loaded', '%R>>%n %_Scriptinfo:%_ Loaded $0 version $1 by $2.'
]);

sub cmd_print_help {
  Irssi::print(<<EOF, MSGLEVEL_CRAP);
$msghead
          /music help           - this one
          /music                - displays last 'music' entry in sql database
EOF
}


sub cmd_music {
   # call last track from database with sql query: select * from music order by id desc limit 1;
    my $current_mp3=`psql -tc "select music from music order by id desc limit 1;"`;
    my ($data, $server, $witem) = @_;

#    if (!$server) {
#        $witem->print("You are not connected to a server.");
#        return;
#    } elsif  (!$witem || $witem->{type} ne "CHANNEL") {
#        $witem->print($witem, 'No active channel in this window.');
#        Irssi::Windowitem::print($channel, "No active channel in this window.");
#        return;
#    }

    $witem->command('me test'.$current_mp3);
}

Irssi::command_bind('help', 'cmd_print_help');
Irssi::command_bind('music', 'cmd_music');

Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'mp3script_loaded', $IRSSI{name}, $VERSION, $IRSSI{authors});