Attention Applescripters
Hey all. Not long ago I downloaded the new version of Mice iRC (1.000 beta 10) and each time I'd open it it would open iTunes if it wasn't already open. At first I was confused as to why this was happening and then I started to look around in the menus and I found that it has/is installed with a music script. When you type /music in an iRC channel it outputs what song is currently playing in your iTunes. With that said, I'd like the script to be edited so that it'll send the output to the iRC channel upon the song's completion. Would there anyone that could be so kind as to edit this script for me for do that?
Here's the script:
-- Sample AppleScript to provide simple connection to iTunes, where typing /music in a channel
-- or query will send what song is currently playing, if any
-- Function to output text to the desired place
on showAction(serverId, panelId, newtext)
\ttell application "iRC"
\t\tset a to (panelType identifier panelId) as string
\t\ttell server id serverId
\t\t\tif a = "channel" then
\t\t\t\ttell channel id panelId
\t\t\t\t\tlocalAction text newtext
\t\t\t\t\taction text newtext
\t\t\t\tend tell
\t\t\tend if
\t\t\tif a = "query" then
\t\t\t\ttell query id panelId
\t\t\t\t\tlocalAction text newtext
\t\t\t\t\taction text newtext
\t\t\t\tend tell
\t\t\tend if
\t\t\tif a = "dcc query" then
\t\t\t\ttell dcc chat id panelId
\t\t\t\t\tlocalAction text newtext
\t\t\t\t\taction text newtext
\t\t\t\tend tell
\t\t\tend if
\t\tend tell
\tend tell
end showAction
on handleCommand(serverId, panelId, channelName, commandname, params)
\tif commandname = "music" then
\t\ttell application "iTunes"
\t\t\tset s to player state as string
\t\t\tif s = "playing" then
\t\t\t\tset a to artist of current track
\t\t\t\tset b to name of current track
\t\t\t\tset c to (a & " - " & b) as string
\t\t\telse
\t\t\t\tset c to "nothing"
\t\t\tend if
\t\t\tset d to "is currently listening to " & c
\t\tend tell
\t\tshowAction(serverId, panelId, d)
\t\treturn 1
\telse
\t\treturn 0
\tend if
end handleCommand
Here's the script:
-- Sample AppleScript to provide simple connection to iTunes, where typing /music in a channel
-- or query will send what song is currently playing, if any
-- Function to output text to the desired place
on showAction(serverId, panelId, newtext)
\ttell application "iRC"
\t\tset a to (panelType identifier panelId) as string
\t\ttell server id serverId
\t\t\tif a = "channel" then
\t\t\t\ttell channel id panelId
\t\t\t\t\tlocalAction text newtext
\t\t\t\t\taction text newtext
\t\t\t\tend tell
\t\t\tend if
\t\t\tif a = "query" then
\t\t\t\ttell query id panelId
\t\t\t\t\tlocalAction text newtext
\t\t\t\t\taction text newtext
\t\t\t\tend tell
\t\t\tend if
\t\t\tif a = "dcc query" then
\t\t\t\ttell dcc chat id panelId
\t\t\t\t\tlocalAction text newtext
\t\t\t\t\taction text newtext
\t\t\t\tend tell
\t\t\tend if
\t\tend tell
\tend tell
end showAction
on handleCommand(serverId, panelId, channelName, commandname, params)
\tif commandname = "music" then
\t\ttell application "iTunes"
\t\t\tset s to player state as string
\t\t\tif s = "playing" then
\t\t\t\tset a to artist of current track
\t\t\t\tset b to name of current track
\t\t\t\tset c to (a & " - " & b) as string
\t\t\telse
\t\t\t\tset c to "nothing"
\t\t\tend if
\t\t\tset d to "is currently listening to " & c
\t\tend tell
\t\tshowAction(serverId, panelId, d)
\t\treturn 1
\telse
\t\treturn 0
\tend if
end handleCommand