iTunes and Colloquy

Hello, hello.

I’ve been a scripter for a few months now, but I’ve barely touched the surface. I began scripting because of this conundrum but as of yet I haven’t figured it out. I was wondering how I could display the current song playing in iTunes as a /me statement in Colloquy for example: “/me is now playing Eight Days a Week -The Beatles.”

Possible?

Thanks!

Model: iBook G4
AppleScript: Not Sure
Operating System: Mac OS X (10.4)

Looking through the application’s library, I found this:

I assume this would allow you to to this. You can try one of these to get the current chat ID


tell application "Colloquy" to get the id of the active chat
tell application "Colloquy" to get the id of the front chat

and then just send that chat a message.


tell application "Colloquy" to send message "is made of mouldy cheese." to (the id of the front chat) action tense true

the ‘action tense true’ replaces adding /me I think. I haven’t got a brilliant way to test this as I don’t really know my way around IRC, but I hope this helps. :slight_smile:

Model: MacBook
AppleScript: 2.3
Browser: Google Chrome
Operating System: Mac OS X (10.6)

But then how would I add iTunes song info (song, artist) to the message

I don’t use chat, and I haven’t scripted anything in iTunes yet, but I would guess you could do something like this:


tell application "iTunes"
	set theName to name of current track
	set theArtist to artist of current track
end tell
tell application "Colloquy" to send message theName & " by " & theArtist to (the id of the front chat) action tense true

If that doesn’t work, you may need to change the last line to


tell application "Colloquy" to send message (theName & " by " & theArtist) to (the id of the front chat) action tense true

I haven’t been scripting long either, and I’m still getting the hang of certain syntax.

The artist portion works just fine, but name doesn’t seem to comply.

And is there anyway for this to repeat every time the song changes?

When I run


tell application "iTunes"
	set theName to title of current track
	set theArtist to artist of current track
end tell

The result is

I don’t know if title works. I tested “set theName to name of current track” and that works fine. I don’t know how to have iTunes announce track changes, though it obviously has the capability since so many plugins rely on it.

Whoops, I tried both in my applescript, and neither were working for me

This script works perfectly for me:


tell application "iTunes"
	set theName to name of current track
	set theArtist to artist of current track
	set theAlbum to album of current track
end tell
display dialog (theName & " by " & theArtist & " on " & theAlbum)

With the result being a dialog box containing “Biography of a Pretend Rock Star by Nick Hensley on Love Songs for Angry Men”

I’m also using 10.4, and the latest version of iTunes supported on 10.4, so I’m not sure what’s going wrong for you.

Once I added the display dialog, it worked fine. So if I wanted to export that to Colloquy, just skip the display and go straight into another tell?

If I do that, then how do I do the send message, everytime I try, I get an error message

Play around with getting Colloquy to send a message to the correct window in the simplest form possible - a “this is a test” type message. Once you get that down, start replacing your test message with the defined variables. I’m not sure what format iTunes sets it’s variables to, but you may need to play around with adding “as text” to them.

Okay, I figured out how to get the iTunes information into Colloquy, but how do I repeat that everytime the song changes in one specific room?



tell application "iTunes"
	set theName to the name of current track
	set theArtist to the artist of current track
	set theAlbum to the album of current track
end tell
tell application "Colloquy" to send message ("is playing " & theName & " by " & theArtist & " | Listen http://radio.pacificorder.net:8002/listen.pls | Query For Requests") with action tense

That I don’t know. But if you figure it out, be sure to post. I’m curious as well.

Try this. Create a smart playlist with the parameters of “Last Played is in the last 1 days” and “Limit to 1 items selected by most recently played” with Live Updating selected. That will create a playlist with whatever song finished playing most recently today. You could then perhaps script around monitoring that playlist for changes and sending a message when the info in the playlist changes.

I couldn’t get that to work at all, any other suggestions?