Yes. I figured I'd post it, since it's so totally amazingly elite.
x86-xmms-xchat.pl#!/usr/bin/perl -w
# http://www.x86labs.org/
# http://www.slacktech.com/~newby/
# Special thanks to whatever tutorials helped me along the way.
# Come chat with us on irc.tehnet.org!
use Xmms::Remote ();
# Register the plugin with X-Chat.
Xchat::register("x86-xmms-xchat", "0.3", "XMMS plugin for X-Chat", \&unload);
Xchat::print("Loading x86-xmms-xchat... please wait.");
# Register the command to a variable.
my $mp3hook = Xchat::hook_command("mp3", \&sendmp3tochannel);
# Randomize the seed!
srand();
# This sub is called whenever the plugin is unloaded.
sub unload()
{
Xchat::unhook($mp3hook);
Xchat::print("Unloading x86-xmms-xchat... please wait.");
}
######################################################################################################################
# This is for the mp3 command stuff. #
######################################################################################################################
sub sendmp3tochannel()
{
my $xmms = Xmms::Remote->new;
if (! $xmms->is_running)
{
Xchat::command("say Error: xmms is not currently running! Boo! Turn on xmms loser! ");
}
else
{
my $song = (($xmms->get_playlist_pos()) + 1);
my $song2 = $xmms->get_playlist_title();
my $songpos = parse_time($xmms->get_output_time);
my $songlen = parse_time($xmms->get_playlist_time);
my @songinfo = $xmms->get_info();
my $prefix = get_prefix();
Xchat::command("me $prefix $song. $song2 [$songpos of $songlen] [".($songinfo[0]/1000)."kbps]");
# my $file = $xmms->get_playlist_file($song);
# We'll finally use this when I get unlazy and figure out how to parse tags out of a file!
}
}
sub parse_time()
{
my $xmms_time = shift;
my $seconds = $xmms_time / 1000;
my $minutes = $seconds / 60;
$seconds = $seconds % 60;
return sprintf("%02d:%02d", $minutes, $seconds);
}
sub get_prefix()
{
open(FILE, "prefix-list.txt") || return "is currently listening to";
my @prefixes = <FILE>;
my $prefix = $prefixes[rand @prefixes];
close(FILE);
chomp($prefix);
return $prefix;
}
Example output:
* newby_ is currently listening to Aggression - Metal Slaughter [02:14 of 03:57] [320kbps]
* newby_ is currently listening to Aggression - Metal Slaughter [02:14 of 03:57] [320kbps]
* newby_ is currently listening to Aggression - Metal Slaughter [02:15 of 03:57] [320kbps]
* newby_ is currently listening to Aggression - Metal Slaughter [02:15 of 03:57] [320kbps]
* newby_ eats babies while listening to Aggression - Metal Slaughter [02:23 of 03:57] [320kbps]
* newby_ starts a circle pit to Tempter - Don't Get Mad...Get Evil [00:16 of 03:53] [320kbps]
* newby_ starts a circle pit to Tempter - Don't Get Mad...Get Evil [00:17 of 03:53] [320kbps]
* newby_ is headbanging to Tempter - Don't Get Mad...Get Evil [00:18 of 03:53] [320kbps]
* newby_ thrashes out to Tempter - Don't Get Mad...Get Evil [00:19 of 03:53] [320kbps]
* newby_ is getting his ass kicked by Tempter - Don't Get Mad...Get Evil [00:20 of 03:53] [320kbps]