IRC::register("Announce","1.0","",""); IRC::print("::Announce v1.0:: [Loaded]"); IRC::add_command_handler("itunes","itunes_announce"); IRC::add_command_handler("vlc","vlc_announce"); IRC::print "Commands: "; IRC::print " /itunes : Announce your current track name on IRC. "; IRC::print " /vlc : Announce your current song or movie name on IRC. "; sub itunes_announce { # this bit is split over multiple lines for readability $parta = "/applescript -o tell application \"iTunes\" to return \"np: [ \002\" "; $partb = "& artist of current track & \" (\" & album of current track & \") - \" & name of current track & \" \002] \""; $partc = $parta . $partb; IRC::command("$partc"); return 1; } sub vlc_announce { $LOGFILE = "/tmp/vlc_log.txt"; $songsplayed = `grep "successfully opened" $LOGFILE | tail -1`; $songsplayed =~ /.+\`(.+)\'.+/s; $lastsong = $1; $lastsong =~ /.+\/(.+)\/(.+)\.\w/; $album = $1; $song = $2; IRC::command ("np: [ ($album) $song ]"); return 1; }