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) {
Irssi::print('You are not connected to a server.')
return;
} elsif (!$witem || $witem->{type} ne "CHANNEL" || $witem->{type} ne "QUERY") {
Irssi::print('Can not message this window.');
return;
}
else
{
$witem->command('me Now playing: '.$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});