#!/usr/bin/perl -w
# Muine XChat Announcer 0.1
# (c) Copyright 2006 - Edwind Contreras <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
#
# This script need muine-shell, please install, muine-shell, a program for
# controlling Muine from the command line, search muine-shell in:
#
# http://desrt.mcmaster.ca/code/muine-shell/
#
use POSIX qw(strftime);
$script_name = "Muine XChat Announcer";
$script_version = "0.1";
$script_description = "Announces the current playing song information from Muine in XChat.";
$muine_version = `muine-shell -V`;
$muine_version =~ s/muine-shell\s//;
$muine_version =~ s/\n//;
#colors table
# Sample Colors:
# \00300 white \00308 yellow
# \00301 black \00309 green
# \00302 royal-blue \00310 dark-turquoise
# \00303 green-light \00311 turquoise
# \00304 red \00312 blue
# \00305 dark_red \00313 pink
# \00306 violett \00314 grey-light
# \00307 orange \00315 dark-grey
$white = "\00300"; #
$orange = "\00307"; #
$grey1 = "\00314"; #
$red = "\00304"; #
$royal_blue = "\00302"; #
#not edit if you don't know this...
IRC::register($script_name,$script_version,$script_description,"");
IRC::print("Loaded \002".$script_name."\002:");
IRC::print("Use \002/mu_help\002 to display a list of commands.");
IRC::add_command_handler("mu","mu_announce");
IRC::add_command_handler("next","mu_next");
IRC::add_command_handler("prev","mu_prev");
IRC::add_command_handler("rep","mu_rep");
IRC::add_command_handler("play","mu_play");
IRC::add_command_handler("pause","mu_pause");
IRC::add_command_handler("song","mu_song");
IRC::add_command_handler("album","mu_album");
IRC::add_command_handler("mu_version","mu_version");
IRC::add_command_handler("mu_help","mu_help");
sub mu_announce
{
$muine_process = `ps ax | grep muine | wc -l`;
if ( $muine_process => 2) {
# Get album name for current playing song.
$song_album = `muine-shell -c | grep album: | sed 's/album://'`;
$song_album =~ s/\n//;
# Get artist name for current playing song.
$song_artist = `muine-shell -c | grep title: | sed 's/title://' | sed 's/.mp3//'`;
$song_artist =~ s/\n//;
# Get track title for current playing song.
$song_title = `muine-shell -c | grep artist: | sed 's/artist://'`;
$song_title =~ s/\n//;
# Get duration of current playing song in seconds.
$song_duration = `muine-shell -c | grep duration: | sed 's/duration://'`;
$song_duration =~ s/\n//;
$song_duration = strftime("%M:%S",localtime($song_duration));;
# edit your's random messages
@mesagge = ("Rocks with", "play", "crazy with", "Crashes his head against", "jumping with", "Mixes with" );
srand;
$bajs = rand @mesagge;
$mesagge = @mesagge[$bajs];
IRC::command("/me ".$royal_blue."".$mesagge.": ".$red."[".$royal_blue."".$song_artist." -".$song_album."".$red." -".$royal_blue."".$song_title."".$red." ] - [".$royal_blue."".$song_duration."".$red."] ");
} else {
IRC::print($muine_process);
IRC::print("Muine is not currently running.");
}
return 1;
}
sub mu_next
{
# Skip to the next track.
eval `muine-shell -n`;
IRC::print("Skipped to next track.");
return 1;
}
sub mu_prev
{
# Skip to the previous track.
eval `muine-shell -p`;
eval `muine-shell -p`;
IRC::print("Skipped to previous track.");
return 1;
}
sub mu_rep
{
# Repet track.
eval `muine-shell -p`;
IRC::print("Repet track.");
return 1;
}
sub mu_play
{
# Start playback.
eval `muine-shell -t`;
IRC::print("Started playback.");
return 1;
}
sub mu_pause
{
# Pause playback.
eval `muine-shell -t`;
IRC::print("Paused playback.");
return 1;
}
sub mu_album
{
# show album window.
eval `muine-shell -a`;
IRC::print("Showing album window...");
return 1;
}
sub mu_song
{
# show song window.
eval `muine-shell -s`;
IRC::print("Showing song window...");
return 1;
}
sub mu_version
{
# Display version information to a channel.
IRC::command("/me is using ".$script_name." ".$script_version." with Muine player & muine-shell ".$muine_version." By Richzendy") ;
return 1;
}
sub mu_help
{
# Display help screen.
IRC::print("\002\037".$script_name." Help:\037\002");
IRC::print(" \002About:\002");
IRC::print(" * Author: Edwind Richzendy Contreras Soto <richzendy\@gmail.com>");
IRC::print(" * URL: http://www.Richzendy.org/");
IRC::print(" * Script Version: ".$script_version);
IRC::print(" * Muine-shell Version: ".$muine_version);
IRC::print(" * XChat Version: ".IRC::get_info(0));
IRC::print(" \002Commands:\002");
IRC::print(" * /mu - Display the current song playing to a channel.");
IRC::print(" * /next - Skip to the next track.");
IRC::print(" * /prev - Skip to the previous track.");
IRC::print(" * /rep - Repet track.");
IRC::print(" * /play - Start playback.");
IRC::print(" * /pause - Pause playback.");
IRC::print(" * /song - Show song selection window.");
IRC::print(" * /album - Show album slection windows.");
IRC::print(" * /mu_version - Display version information for the script, muine and XChat to a channel.");
IRC::print(" * /mu_help - Display this help screen.");
return 1;
}