# For this script to work you have to go to xmms options and configure # your "Song Change" (general plug in) to execute the following # command on a song change: # # echo "%sµ%lµ%Fµ%cµ%fµ%rµ%t" > ~/.xmms/playing.txt # # Note: You have to change the last part if you change the name # of $datafile (see below)... and such. # # This code belongs to the public domain. IRC::register("xmms-playing", "2.0","", ""); IRC::print "Loaded xmms-playing 2.0"; IRC::print "Usage: /playing"; IRC::print " /play_options"; IRC::print " /play_toggle "; IRC::add_command_handler("playing", "showPlaying"); IRC::add_command_handler("play_options", "showOptions"); IRC::add_command_handler("play_toggle", "toggleOption"); IRC::add_message_handler("PRIVMSG", send_file); my $datafile = "$ENV{HOME}/.xmms/playing.txt"; # see showOptions my @options = (1, 0, 0, 0, 0, 0, 1); # Set this to the command people should type to trigger a dcc send of your currently # playing mp3 my $send_command = "!pitta"; # send file!! sub send_file { if(@options[6] == 0) { return 0;} my @b = split(":", shift); if(@b[2] eq $send_command) { my @host = split("!", @b[1]); my $nick = @host[0]; my $songdata = getData(); my @a = split("µ", $songdata); my $daCommand = "/dcc send ".$nick." \"".@a[4]."\""; IRC::command($daCommand); return 1; } return 0; } sub toggleOption { $nr = shift; if($nr eq "allon") { my $i = 0; while($i <= 6) { @options[$i++] = 1; } IRC::print "all options set to 1"; return 1; } if($nr eq "alloff") { my $i = 0; while($i <= 6) { @options[$i++] = 0; } IRC::print "all options set to 0"; return 1; } if($nr >= 0 && $nr <= 6) { if(@options[$nr]) { @options[$nr]--; } else { @options[$nr]++; } IRC::print "option $nr changed to: ".@options[$nr]; } else { IRC::print "No such options (use a number of 0 to 5)"; } return 1; } sub showOptions { IRC::print "0. show lenght: ".@options[0]; IRC::print "1. show frequency (in hertz): ".@options[1]; IRC::print "2. show channels: ".@options[2]; IRC::print "3. show filename: ".@options[3]; IRC::print "4. show bitrate: ".@options[4]; IRC::print "5. show location in playlist: ".@options[5]; IRC::print "6. upload allowed: ".@options[6]; return 1; } sub getData { open(X, $datafile); my $data = ; close (X); chop($data); return $data; } sub showPlaying { my @a; my $i = 1; my $mins = 0; my $secs = 0; my $output = ""; my $songdata = ""; $songdata = getData; # In the array: # # 0: song title # 1: length in milliseconds # 2: frequency in hertz # 3: channels # 4: filename # 5: bitrate (bits per second) # 6: playlist position @a = split("µ", $songdata); #IRC::print @a[1]; $secs = (int ($a[1] / 1000)); $mins = (int ($secs / 60)); $secs -= ($mins*60); # must be a better way for this... if($secs <= 9) { $secs = "0".$secs; } if(@options[5]) { $output = "/me is playing: #".$a[6]." ".@a[0]; } else { $output = "/me is playing: ".@a[0]; } # Not good at all ... if(@options[0]) { $output .= " ".$mins.":".$secs; } if(@options[1]) { $output .= ", ".$a[2]." Hertz"; } if(@options[2]) { $output .= ", ".$a[3]." channels"; } if(@options[3]) { $output .= ", filename: ".$a[4]; } if(@options[4]) { $output .= ", ".($a[5]/1000)." kbps"; } if(@options[6]) { $output .= " (".$send_command.")"; } IRC::command($output); return 1; }