All pastes #639693 Raw Edit

Miscellany

public text v1 · immutable
#639693 ·published 2007-07-30 20:03 UTC
rendered paste body
#!/usr/bin/perl

Xchat::register("XMMS Script for XChat", "1.0", "This is a /xmms perl script for XChat on Linux", "");
Xchat::print"» Loaded XMMS Script Version 1.0 successful from necr0mancer on irc://irc.darkstarlings.com/unholy - Try /xmms help «";
Xchat::hook_command("xmms", "xmms_main");
Xchat::hook_command("mp3", "xmms_main");
Xchat::hook_command("np", "xmms_main");


use strict;
use Xmms::Remote ();
my $remote = Xmms::Remote->new();


sub xmms_main {
	my $runs = $remote->is_running;
	my $arg = $_[0][1];
	if($runs == 0){
		Xchat::print"..:: XMMS isn't running. ::..";
	}
	elsif($arg eq 'show' or !$arg){
		my($rate, $freq, $chans) = $remote->get_info;
		my $title = $remote->get_playlist_title;
		$title =~ s/_[^_]*_[^_]*_/ - /;
		$rate = int($rate/1000);
		$freq = int($freq/1000);
		Xchat::command("me is listening to .: $title ($rate kBit/$freq kHz/$chans channels) :.");
	}
	elsif($arg eq 'stop' or $arg eq 'pause'){
		$remote->stop;
		Xchat::print"..:: XMMS stopped. ::..";
	}
	elsif($arg eq 'play' or $arg eq 'start'){
		$remote->play;
		Xchat::print"..:: XMMS will play a song now. ::..";
	}
	elsif($arg eq 'volume' or $arg eq 'vol'){
		my $volume = $_[0][2];
		unless(defined $volume){
			Xchat::print"..:: You have to enter a volume. Use: /xmms volume <int>. ::..";
		}
		elsif($volume <= 100 and $volume >= 0){
			$remote->set_main_volume("$volume");
			Xchat::print"..:: Set main volume to $volume ::..";
		} else {
			Xchat::print"..:: $volume isn't allowed. Please choose a value between 0-100. ::..";
		}
	}
	elsif($arg eq 'help'){
		Xchat::print"..:: Help for XMMS script. ::..";
		Xchat::print"/xmms show - Shows your current playing song.";
		Xchat::print"/xmms play - Plays a song in XMMS.";
		Xchat::print"/xmms stop - Stops playing a song in XMMS.";
		Xchat::print"/xmms volume <int> - Sets volume of XMMS to <int>.";
		Xchat::print"/xmms help - Shows this  help.";
		Xchat::print"..:: End Help ::..";
	} else {
		Xchat::print"..:: $arg isn't a valid argument, please have a look at /xmms help. ::..";
	}
}