IRC now playing script?

Discuss Play, an open source multi-format audio player.
Post Reply
psx1337
Posts: 3
Joined: Wed Mar 05, 2008 7:18 am

IRC now playing script?

Post by psx1337 » Wed Mar 05, 2008 7:20 am

Hi. I really like this audio player. The only thing I miss is that iTunes would be able to broadcast my current track to irc (x-chat aqua) and also show it as my status on Adium. Is there any way to do this with Play?

User avatar
sbooth
Site Admin
Posts: 2445
Joined: Fri Dec 23, 2005 7:45 am
Location: USA
Contact:

Re: IRC now playing script?

Post by sbooth » Wed Mar 05, 2008 6:24 pm

Play broadcasts system-wide notifications when tracks start, stop, etc. This is how iScrobbler works with Play; the notifications are deliberately similar to iTunes' for compatibility purposes. How does x-chat aqua get the information from iTunes? With that information it would be possible to determine how to do this.

psx1337
Posts: 3
Joined: Wed Mar 05, 2008 7:18 am

Re: IRC now playing script?

Post by psx1337 » Wed Mar 05, 2008 8:34 pm

Hi sbooth. X-Chat Aqua uses a plugin named irctunes.pl I'll paste the code:

#!/usr/bin/perl -w

use IPC::Open2;

#
# iRCTunes XCA - Give iTunes the Power to Communicate.
#
# Developer : Michael Brice <imac600x@gmail.com>
# Website : http://www.irctunes.co.nr
# Last update : 12/08/2007 (August 12th 2007)
#
# ============================================================================================================= #
# MAKE MODIFICATIONS HERE ONLY (READ FIRST)
# ============================================================================================================= #

# The iRCTunes theme system uses tags to insert information from a query. Some valid ones are <track>, <player>
# and <album> for display, <minute>, <position> and <length> for time, and <rate> for the bitrate, <stream> for
# the streaming status and <version> for the QuickTime Version. Colour codes are inserted as \003XX (XX being the
# colour number, 00315 for example) and the tag closed with "\017". Bolds are done the same way but require
# "\002" rather than "\003XX". If you plan to insert quotes, place a slash (\) before them.

my $main = "/me is playing \002\"<track>\"\017 by \002<player>\017 on \002<album> [<minute>:<position>-<length>/<rate>kbps]";
my $video = "/me is playing \002\"<track>\"\017 [QT<version>]";
my $radio = "/me is tuned to \002\"<stream>\"\017 at \002<track>\017 [<minute>:<position>/<rate>kbps]";


# The Menu Control is enabled in all new binaries. It adds an iTunes menu in the menu bar for X-Chat Aqua. Add
# a comment (#) to disable and remove the comment (if present) to enable.

&menuctrl;


# The Button Control is disabled by default in all new binaries. It adds an iRCTunes remote in the userlist
# buttons, but has a few stability issues in some versions of X-Chat Aqua and uses a lot of space. Add a comment
# (#) to disable and remove the comment (if present) to enable.

#&btnctrl;


# ============================================================================================================= #
# DO NOT EDIT BELOW THIS LINE.
# ============================================================================================================= #

my $script_name = "iRCTunes";
my $script_version = '2.0.2';
my $script_description = 'Give iTunes the Power to Communicate.';
my $pkg = __PACKAGE__;
my $script_host = 'X-Chat Aqua';
my $script_date = "12/08/2007";
my $sversion = '2020';

IRC::register($script_name,$script_version, "",$script_description);
IRC::print (" ");
IRC::print ("\002$script_name $script_version ($script_date)\017\n");
IRC::print ("Copyright 2007 Michael Brice & iRCTunes DG.");

my $get_track = qq(tell application "iTunes"
set this_name to the name of current track
set this_artist to the artist of current track
set this_album to the album of current track
set this_rating to the rating of current track
set this_length to the time of current track
set this_bitrate to the bit rate of current track
set this_playcount to the played count of current track
set this_position to player position
set this_minute to 0
repeat while this_position > 60
set this_minute to this_minute + 1
set this_position to this_position - 60
end repeat
end tell
if this_position > 9 then
return this_name & tab & this_artist & tab & this_rating & tab & this_length & tab & this_bitrate & tab & this_album & tab & this_playcount & tab & this_minute & tab & this_position
else
return this_name & tab & this_artist & tab & this_rating & tab & this_length & tab & this_bitrate & tab & this_album & tab & this_playcount & tab & this_minute & tab & 0 & this_position
end if);

my $get_radio = qq(tell application "iTunes"
set this_name to the name of current track
set this_stream to the current stream title
set this_bitrate to the bit rate of current track
set this_position to player position
set this_minute to 0
repeat while this_position > 60
set this_minute to this_minute + 1
set this_position to this_position - 60
end repeat
end tell
if this_position > 9 then
return this_name & tab & this_stream & tab & this_bitrate & tab & this_minute & tab & this_position
else
return this_name & tab & this_stream & tab & this_bitrate & tab & this_minute & tab & 0 & this_position
end if);

my $get_video = qq(tell application "QuickTime Player"
set this_name to the name of document 1
set this_version to (QuickTime version as string)
set this_stream to the live stream of document 1
end tell
return this_name & tab & this_version & tab & this_stream);

$get_track = join ("' -e '",$get_track);
$get_video = join ("' -e '",$get_video);

IRC::add_command_handler("iTunes", "${pkg}::iTunes");
IRC::add_command_handler ("send", "send");

sub iTunes(){
$options = shift;
$options =~ s/\s+/ /g;
($todo,$where,$rest) = split(/\s/,$options);
$arg = shift(@_);
if($todo =~ /^show$/i){
&show;
}elsif($todo =~ /^video/i){
&video;
}elsif($todo =~ /^broadcast/i){
&broadcast;
}elsif($todo =~ /^radio/i){
&radio;
}elsif($todo =~ /^restart/i){
&restart;
}elsif($todo =~ /^next$/i){
&next_track;
}elsif($todo =~ /^prev/i){
&prev_track;
}elsif($todo =~ /^muteon/i){
&muteon;
}elsif($todo =~ /^muteoff/i){
&muteoff;
}elsif($todo =~ /^volume/i){
&volume;
}elsif($todo =~ /^status/i){
&status;
}elsif($todo =~ /^echo$/i){
&echo;
}elsif($todo =~ /^play$/i){
&play;
}elsif($todo =~ /^rewind/i){
&rewind;
}elsif($todo =~ /^stop/i){
&stop;
}elsif($todo =~ /^pause/i){
&pause;
}elsif($todo =~ /^shuffle/i){
&shuffle;
}elsif($todo =~ /^playlist/i){
&playlist;
}elsif($todo =~ /^help/i){
&help;
}elsif($todo =~ /^about/i){
&about;
}elsif($todo =~ /^tab/i){
&tab;
}elsif($todo =~ /^set/i){
&toggle_variable;
}elsif($todo =~ /^update/i){
&update;
}elsif($todo =~ /^checkver/i){
&checkver;
}elsif($todo =~ /^build/i){
&build;
}elsif($todo =~ /^showabout/i){
&showabout;
}elsif($todo =~ /^support/i){
&support;
}elsif($todo =~ /^send/i){
&senderror;
}else{
IRC::print("\002iRCTunes didn't understand your command. Type '/itunes help' or press the 'Help' button for more info\017");
}
return 1;
}

sub show{
$temp = qx(osascript -e '$get_track');
$temp =~ s/\n//g;
$temp =~ s/\tmissing value\t/\t\t/g;
$temp =~ s/\tmissing value$/\t/g;
($track,$player,$rate,$duration,$bitrate,$album,$playcount,$minute,$position) = split(/\t/,$temp);
if($player eq ""){
@temp = ("Unknown Artist");
$player = $temp[int(rand(@temp))];
}
if($track =~ /^\s*$/){
if($where =~ /me/i){
$track = "/echo You currently have iTunes stopped.";
}else{
$track = "/echo You currently have iTunes stopped.";
}
}else{
if($where =~ /me/i){
$track = $track." [by $player]";
}else{
$line = $main;
$line =~ s/<track>/$track/gi;
$line =~ s/<player>/$player/gi;
$line =~ s/<length>/$duration/gi;
$line =~ s/<rate>/$bitrate/gi;
$line =~ s/<album>/$album/gi;
$line =~ s/<playcount>/$playcount/gi;
$line =~ s/<minute>/$minute/gi;
$line =~ s/<position>/$position/gi;
$track = $line;
}
}
&output($track,$where);
}

sub broadcast {
$temp = qx(osascript -e '$get_track');
$temp =~ s/\n//g;
$temp =~ s/\tmissing value\t/\t\t/g;
$temp =~ s/\tmissing value$/\t/g;
($track,$player,$rate,$duration,$bitrate,$album,$playcount,$minute,$position) = split(/\t/,$temp);
if($player eq ""){
@temp = ("Unknown Artist");
$player = $temp[int(rand(@temp))];
}if($track =~ /^\s*$/){
if($where =~ /ame/i){
$track = "/echo You currently have iTunes stopped.";
}else{
$track = "/echo You currently have iTunes stopped.";
}
}else{
if($where =~ /ame/i){
$track = $track." [by $player]";
}else{
$line = $main;
$line =~ s/<track>/$track/gi;
$line =~ s/<player>/$player/gi;
$line =~ s/<length>/$duration/gi;
$line =~ s/<rate>/$bitrate/gi;
$line =~ s/<album>/$album/gi;
$line =~ s/<playcount>/$playcount/gi;
$line =~ s/<minute>/$minute/gi;
$line =~ s/<position>/$position/gi;
$track = $line;
}
}
&castout($track,$where);
}

sub video {
$temp = qx(osascript -e '$get_video');
$temp =~ s/\n//g;
$temp =~ s/\tmissing value\t/\t\t/g;
$temp =~ s/\tmissing value$/\t/g;
($track,$version,$stream,$bitrate) = split(/\t/,$temp);
if($track =~ /^\s*$/){
if($where =~ /me/i){
$track = "/echo You currently have QuickTime stopped.";
}else{
$track = "/echo You currently have QuickTime stopped.";
}
}else{
if($where =~ /me/i){
$track = $track." ";
}else{
$line = $video;
$line =~ s/<track>/$track/gi;
$line =~ s/<stream>/$stream/gi;
$line =~ s/<version>/$version/gi;
$track = $line;
}
}
&output($track,$where);
}

sub radio{
$temp = qx(osascript -e '$get_radio');
$temp =~ s/\n//g;
$temp =~ s/\tmissing value\t/\t\t/g;
$temp =~ s/\tmissing value$/\t/g;
($track,$stream,$bitrate,$minute,$position) = split(/\t/,$temp);
if($player eq ""){
@temp = ("Unknown Artist");
$player = $temp[int(rand(@temp))];
}if($track =~ /^\s*$/){
if($where =~ /me/i){
$track = "/echo You currently have iTunes Radio stopped.";
}else{
$track = "/echo You currently have iTunes Radio stopped.";
}
}else{
if($where =~ /me/i){
$track = $track." [by $player]";
}else{
$line = $radio;
$line =~ s/<track>/$track/gi;
$line =~ s/<rate>/$bitrate/gi;
$line =~ s/<stream>/$stream/gi;
$line =~ s/<minute>/$minute/gi;
$line =~ s/<position>/$position/gi;
$track = $line;
}
}
&output($track,$where);
}

sub next_track {
my $next_track = qq(tell application "iTunes"
next track
end tell);
$next_track = join ("' -e '",$next_track);
$track = qx(osascript -e '$next_track');
unless($operate_quiet){
$track = qx(osascript -e '$get_track');
$track =~ s/\n//g;
$track =~ s/\t/ \- /g;
IRC::print($track);
}
}

sub prev_track {
my $next_track = qq(tell application "iTunes"
previous track
end tell);
$next_track = join ("' -e '",$next_track);
$track = qx(osascript -e '$next_track');
unless($operate_quiet){
$track = qx(osascript -e '$get_track');
$track =~ s/\n//g;
$track =~ s/\t/ \- /g;
IRC::print($track);
}
}

sub volume{
if($where =~ /^up$/i){
$volume = "sound volume + 11";
}elsif($where =~ /^down$/i){
$volume = "sound volume - 9";
}elsif($where =~ /^\d+$/){
$volume = $where + 1;
}else{
IRC::print($backred."Sorry, bad volume value (you can use 'up', 'down' and a number between 0 and 100)");
return 1;
}
my $next_track = qq(tell application "iTunes"
set sound volume to $volume
return sound volume
end tell);
$next_track = join ("' -e '",$next_track);
$track = qx(osascript -e '$next_track');
$track =~ s/\n//g;
$where = $rest;
if($where =~ /me/i){
$track = "iTunes sound volume is on $track/100";
}else{
$track = "has iTunes sound volume on $track/100";
}unless($operate_quiet){
}
}

sub muteon {
Xchat::command("applescript -o tell application \"iTunes\" to set mute to true");
}

sub muteoff {
Xchat::command("applescript -o tell application \"iTunes\" to set mute to false");
}

sub status {
my $next_track = qq(tell application "iTunes"
return player state
end tell);
$next_track = join ("' -e '",$next_track);
$track = qx(osascript -e '$next_track');
$track =~ s/\n//g;
if($where =~ /me/i){
$track = "iTunes is $track";
}else{
$track = "has iTunes $track";
}&output($track,$where);
}

sub play {
my $next_track = qq(tell application "iTunes"
play
end tell);
$next_track = join ("' -e '",$next_track);
$track = qx(osascript -e '$next_track');
$track = qx(osascript -e '$get_track');
$track =~ s/\n//g;
unless($operate_quiet){
$track =~ s/\t/ \- /g;
IRC::print($track);
}
}

sub echo {
$next_track = join ("' -e '",$next_track);
$track = qx(osascript -e '$next_track');
$track = qx(osascript -e '$get_track');
$track =~ s/\n//g;
unless($operate_quiet){
$track =~ s/\t/ \- /g;
IRC::print($track);
}
}

sub rewind {
my $next_track = qq(tell application "iTunes"
back track
end tell);
$next_track = join ("' -e '",$next_track);
$track = qx(osascript -e '$next_track');
unless($operate_quiet){
$track = qx(osascript -e '$get_track');
$track =~ s/\n//g;
$track =~ s/\t/ \- /g;
IRC::print($track);
}
}

sub stop {
my $next_track = qq(tell application "iTunes"
stop
end tell);
$next_track = join ("' -e '",$next_track);
$track = qx(osascript -e '$next_track');
unless($operate_quiet){
IRC::print("iTunes playing stopped");
}
}

sub pause {
my $next_track = qq(tell application "iTunes"
playpause
return player state
end tell);
$next_track = join ("' -e '",$next_track);
$track = qx(osascript -e '$next_track');
unless($operate_quiet){
IRC::print("iTunes $track");
}
}

sub shuffle {
my $query = $_[1][1];
Xchat::command("applescript -o tell application \"iTunes\" to tell current playlist to play some track");
if($personal_announce_coms) { Xchat::command("pnp");
}my $next_track = qq(tell application "iTunes"
play
end tell);
$next_track = join ("' -e '",$next_track);
$track = qx(osascript -e '$next_track');
$track = qx(osascript -e '$get_track');
$track =~ s/\n//g;
unless($operate_quiet){
$track =~ s/\t/ \- /g;
}
}

sub playlist
{
my $query = $_[1][1];
if ($query ne ""){
Xchat::command("applescript -o tell application \"iTunes\" to play some track of playlist \"selection\"");
return 1;
}else{
my $playlist_list = "set placehold to 0
set thelist to {}
tell application \"iTunes\" to set thecount to the count of playlist
repeat while placehold < thecount
set placehold to placehold + 1
tell application \"iTunes\" to copy the name of playlist placehold to the end of thelist
end repeat
choose from list thelist
set theresult to the result
if theresult is not false then
tell application \"iTunes\" to play some track of playlist named theresult
end if";
Xchat::command("applescript $playlist_list");
return 1;
}
}

sub help {
IRC::print(" ");
IRC::print(chr(3)."1,11".$bold."iRCTunes $script_version for $script_host Help ");
IRC::print(" ");
IRC::print(" /itunes show : Displays playing track");
IRC::print(" /itunes video : Displays playing video");
IRC::print(" /itunes radio : Displays the current playing station");
IRC::print(" /itunes echo : Displays Playing Track to the User Only");
IRC::print(" /itunes broadcast: Displays Playing Track in All Open Channels");
IRC::print(" ");
IRC::print(chr(3)."1,11".$bold."Control Settings ");
IRC::print(" ");
IRC::print(" /itunes play : Start playing track");
IRC::print(" /itunes stop : Stop playing track");
IRC::print(" /itunes pause : Toggle play/pause");
IRC::print(" /itunes status : Display iTunes playing status");
IRC::print(" /itunes next : Move to next track");
IRC::print(" /itunes prev : Move to previous track");
IRC::print(" /itunes rewind : Go back to beginning of the current track");
IRC::print(" /itunes shuffle : Jumps to a completely random song");
IRC::print(" /itunes playlist : Allows you to select a playlist to play.");
IRC::print(" ");
IRC::print(chr(3)."1,11".$bold."Volume Settings ");
IRC::print(" ");
IRC::print(" /itunes volume : Set & display iTunes volume");
IRC::print(" Volume options : Up, down or a number from 0 till 100");
IRC::print(" /itunes muteon : Turn Mute On.");
IRC::print(" /itunes muteoff : Turn Mute Off.");
IRC::print(" ");
IRC::print(chr(3)."1,11".$bold."Config Settings ");
IRC::print(" ");
IRC::print(" /send itunes : Sends Current Playing Track via DCC.");
IRC::print(" /itunes checkver : Checks for New Versions without installing.");
IRC::print(" /itunes update : Checks for New Versions and Installs Updates.");
IRC::print(" /itunes restart : Restart the iRCTunes Extension.");
IRC::print(" /itunes tab : Opens a Dedicated iRCTunes tab.");
IRC::print(" /itunes help : Displays this Help Menu");
IRC::print(" /itunes support : Opens the Support Console");
IRC::print(" /itunes about : Displays Script Information");
IRC::print(" /itunes showabout: Displays Script Information to the Channel");
IRC::print(" ");
IRC::print(chr(3)."1,11".$bold."Copyright 2007 Michael Brice @ iRCTunes DG. (http://www.irctunes.co.nr) ");
IRC::print(" ");
}

sub showabout {
if($debug){
IRC::print($about);
}
if($info =~ /^\s*$/){
if($where =~ /me/i){
$about = "Powered By $script_name $script_version";
}else{
$about = "/me uses \002$script_name $script_version\017 for $script_host. (http://www.irctunes.co.nr)";
}
}
&output($about,$where);
}

sub about {
IRC::print (" ");
IRC::print ("\002$script_name $script_version (\002$script_date\017)\002\n");
IRC::print ("Copyright 2007 Michael Brice & iRCTunes DG.");
IRC::print (" ");
}

sub support {
Xchat::command("applescript -o display dialog \"For more iRCTunes Help & Support, click one of the buttons below.\" & return & return buttons {\"Cancel\", \"Forum\", \"Channel\"} default button 3
if button returned of result is \"Forum\" then
open location \"http://www.mac.profusehost.net/forum/in ... ?board=3.0\"
else if button returned of result is \"Channel\" then
open location \"irc://irc.moofspeak.net/scripts\"
end if");
}

sub tab {
Xchat::command("dialog iRCTunes");
}

sub senderror {
IRC::print(" ");
IRC::print("You must use this from the command line. Type '/send itunes <nick>' to send the current playing track to a user.");
IRC::print(" ");
}
sub send {
$arg = shift(@_);
for ($arg) {
if (/itunes/) {
@args=split(' ',$arg);
my ($data) = shift(@args);
IRC::print("Usage: /dcc itunes <user>\n"), return -1 if $data =~ /^\s*$/;
{
&senddata(@args);
}
return 1;
}
}
}
sub senddata {
my ($nick) = @_;
my $get_path = "tell application \"iTunes\"
set j to the location of current track
set j to posix path of j
end tell
set j to \"".'\"'."\" & j & \"".'\"'."\" as string
return j";
my $file = `osascript -e \'$get_path\'`;
chomp($file);
$file = $nick ."\t". $file;
&auto_get_file($file);
}
sub auto_get_file(){
my ($file) = @_;
@args=split('\t',$file);
IRC::command("/DCC SEND ".$args[0]." $args[1]");
return 1;
}

sub update {
system "curl http://irctunes.50webs.com/updater/xca.ver -o Plugins/irctunes.ver";
open(TEMP,"Plugins/irctunes.ver");
@temp_file=<TEMP>;
close (TEMP);
system "rm -f Plugins/irctunes.ver";
$getvers=$temp_file[0];
if ($getvers > $sversion){
IRC::print("\00312Connecting to Server...\017");
IRC::print("\00312Downloading Latest...\017");
system "curl http://irctunes.50webs.com/updater/xca.upd -o Plugins/irctunes.pl";
$restart;
Xchat::command("applescript -o display dialog \"iRCTunes has been Updated.\" buttons {\"OK\"} default button 1");
}else{
IRC::print("This Version is \00303Up-To-Date\017\n\n");
}
return 1;
}

sub checkver {
system "curl http://irctunes.50webs.com/updater/xca.ver -o Plugins/irctunes.ver";
open(TEMP,"Plugins/irctunes.ver");
@temp_file=<TEMP>;
close (TEMP);
system "rm -f Plugins/irctunes.ver";
$getvers=$temp_file[0];
if ($getvers > $sversion){
IRC::print("\00314A New Version is Available. Please Run Update.\017");
}else{
IRC::print("This Version is \00303Up-To-Date.\017\n\n");
}
return 1;
}

sub btnctrl {
# Line 6
Xchat::command("delbutton Pause");
Xchat::command("addbutton Pause iTunes pause");
Xchat::command("delbutton Help");
Xchat::command("addbutton Help iTunes help");
# Line 5
Xchat::command("delbutton Back");
Xchat::command("addbutton Back iTunes prev");
Xchat::command("delbutton next");
Xchat::command("addbutton Next iTunes Next");
# Line 4
Xchat::command("delbutton Play");
Xchat::command("addbutton Play iTunes play");
Xchat::command("delbutton Stop");
Xchat::command("addbutton Stop iTunes stop");
# Line 3
Xchat::command("delbutton Playlist");
Xchat::command("addbutton Playlist iTunes playlist");
Xchat::command("delbutton Shuffle");
Xchat::command("addbutton Shuffle iTunes shuffle");
# Line 2
Xchat::command("delbutton Video");
Xchat::command("addbutton Video iTunes video");
Xchat::command("delbutton radio");
Xchat::command("addbutton Radio iTunes Radio");
# Line 1
Xchat::command("delbutton Show");
Xchat::command("addbutton Show iTunes show");
Xchat::command("delbutton Broadcast");
Xchat::command("addbutton Broadcast iTunes broadcast");
}

sub menuctrl {
Xchat::command("menu DEL iTunes");
Xchat::command("menu ADD iTunes");
Xchat::command("menu add \"iTunes/iRCTunes XCA \" \"itunes about\"");
Xchat::command("menu add iTunes/-");
Xchat::command("menu add iTunes/Show \"itunes show\"");
Xchat::command("menu add iTunes/Video \"itunes video\"");
Xchat::command("menu add iTunes/Radio \"itunes radio\"");
Xchat::command("menu add iTunes/Broadcast \"itunes broadcast\"");
Xchat::command("menu add iTunes/Echo \"itunes echo\"");
Xchat::command("menu add iTunes/-");
Xchat::command("menu add iTunes/Play \"itunes play\"");
Xchat::command("menu add iTunes/Stop \"itunes stop\"");
Xchat::command("menu add iTunes/Pause \"itunes pause\"");
Xchat::command("menu add iTunes/Next \"itunes next\"");
Xchat::command("menu add iTunes/Previous \"itunes prev\"");
Xchat::command("menu add iTunes/Rewind \"itunes rewind\"");
Xchat::command("menu add iTunes/Status \"itunes status\"");
Xchat::command("menu add iTunes/Shuffle \"itunes shuffle\"");
Xchat::command("menu add iTunes/Playlist \"itunes playlist\"");
Xchat::command("menu add iTunes/-");
Xchat::command("menu add \"iTunes/Volume\" \"itunes volume\"");
Xchat::command("menu add \"iTunes/Mute\" \"itunes muteon\"");
Xchat::command("menu add \"iTunes/Unmute\" \"itunes muteoff\"");
Xchat::command("menu add iTunes/-");
Xchat::command("menu add \"iTunes/Send File\" \"itunes send\"");
Xchat::command("menu add \"iTunes/Help\" \"itunes help\"");
Xchat::command("menu ADD \"iTunes/Support\" \"itunes support\"");
Xchat::command("menu add \"iTunes/About\" \"itunes about\"");
Xchat::command("menu ADD \"iTunes/Update\" \"itunes update\"");
Xchat::command("menu ADD \"iTunes/Restart\" \"itunes restart\"");
}

sub restart {
Xchat::command("unload irctunes.pl");
Xchat::command("load Plugins/irctunes.pl");
}
sub iTunes_running(){
$temp = qx(ps x);
@temp = split(/\n/,$temp);
@temp = grep(/iTunes.app/,@temp);

if($#temp >= 0){ return 1; } else { return 0; }
}
sub value_ok
{
my $thing = shift;
return undef unless defined $thing;
return undef unless length $thing;
return undef if $thing eq 'missing value';
return 1;
}
sub osascript {
my $script = shift;
my ($read, $write);
my $pid = IPC::Open2::open2($read, $write, 'osascript');
print $write qq(tell application "iTunes"\n), $script, qq(\nend tell\n);
close $write;
my $data = do { local $/; <$read> };
close $read;
waitpid $pid, 0;
return $data;
}
sub output(){
($what,$where) = @_;
$what =~ s/\t/ \- /g;
if($where =~ /^me$/i){
IRC::print(chr(3)."1,8".$what.chr(15));
}else{
IRC::command("$what");
}
}
sub noticeio(){
($what,$where) = @_;
my $channel = Xchat::get_info( "channel" );
$what =~ s/\t/ \- /g;
if($where =~ /^me$/i){
IRC::print(chr(3)."1,8".$what.chr(15));
}else{
IRC::command("/notice $channel $what");
}
}
sub castout(){
($what,$where) = @_;
$what =~ s/\t/ \- /g;
if($where =~ /^ame$/i){
IRC::print(chr(3)."1,8".$what.chr(15));
}else{
IRC::command("/ame $what");
}
}

&checkver;

1;
# end

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest