Sending Files under Adium

I wrote a small AppleScript that sends the currently playing iTunes track to the current chat user in Adium. The only tricky part was that the line:

send the active chat of the first interface controller file filename

requires Adium to be the frontmost application: you cannot test this with Script Editor, only install the code as a an AdiumScript and then run it from within Adium. Since it is usually illegal to copy music, all of the usual disclaimers apply: only use this to send music to which you own the copyright, or is in the public domain. Here’s the full code, if you want the whole thing, email or IM me.

on substitute()     tell application “System Events”         try             get process “iTunes”         on error             return         end try     end tell          tell application “iTunes”         set filename to location of current track     end tell          tell application “Adium”         send the active chat of the first interface controller file filename     end tell          return theChat end substitute

Reconnect all Adium Accounts.

Just a little quickie: sometimes Adium loses connections. This script will reconnect any disconnected accounts.

1    tell application "Adium"
2        repeat with acc in accounts
3            connect acc
4        end repeat
5    end tell

Who Else Am I Chatting To?

Not that this has ever come up, but there is an AppleScript out there somewhere that allows you to type %_who into Adium, and it returns a list of people you are chatting to.

Naturally, it was sub-standard, and I have improved it.

Features mine has:<ul> <li>Don’t display the name of the person who you say this to</li> <li>Display “I’m not chatting to anyone else.” if you aren’t</li> <li>If the person you are chatting to can handle HTML in chat (Jabber, AIM), then list display names of the people you are chatting to, with each person a clickable link that will open a chat with that person</li> <li>Otherwise, display a list of people you are chatting to, with the type of chat listed after each name</li> </ul>

I’ve included the old one if anyone was interested: you can get it by typing %_who. Mine uses /who, and you can download it from Adium Xtras.

HTML over various IM systems.

I started out using AIM via .Mac, as that is the default (only?) system for iChat. When I downloaded Adium, I discovered that you can have HTML in your chats. I don’t know (care?) how other clients handle that: but I did find out something just now. Apparently MSN and Yahoo IM don’t handle HTML in messages too well. Jabber (via Google Talk) does this just fine. I may have to code into the /itunes script a check for what account type, and only HTMLify those connections which can handle it.

Google Talk

In case you haven’t heard, Google has ‘released’ their IM system - it’s just a Jabber server, though. There are a couple of review around, and I haven’t read all of them in that much detail. It requires a Gmail account: I have plenty of invites if you want one, just email me. The settings you need are (I use Adium, your client’s names may vary): Account Type: Jabber Jabber ID: Password: •••••••• Connect Server: Port: 5222 Security: Use TLS Encryption (if possible) - I couldn’t get a connection without this, some have said opposite. Others have said that any person with whom you have shared Gmail will be automatically added to your buddy list. I haven’t had anyone added to mine, but then I don’t really Gmail many people. I’ve also created accounts with the other IM players, you can find them under the Contact page.

Adium & Camino

I’m a latecomer to Instant Messaging. I’ve only just discovered it, and part of that is because I don’t have many people to talk to over it. I have written one thing though, and that’s an improvement to megalogeek’s %_camino script. You can download it from Adium Xtras: Camino Current Page. Source follows after the jump!

1on substitute()     
2    tell application "Camino"         
3        URL of window 1         
4        set myURL to the result         
5        set myTitle to name of window 1     
6    end tell     
7    return "<HTML><A HREF=\"" & myURL & "\">" & myTitle & "</A></HTML>" 
8end substitute

Adium Goodness

Since it’s my current fascination, I thought I’d create a new post on Adium. I might have to create a category for it! Anyway, I worked on improving a script I had downloaded that allowed typing %_nowplaying into Adium, and getting a nicely formatted string, including a musical symbol, sent as a message. I made it so that it used the keyword /itunes, and had a link to a google search for the artist’s name. I’d also like to be able to set it up so that the track was a link to download the file from the computer the user is on (would require a webserver to be running, and have read access to the iTunes library folder). And, my version also puts the rating as stars after the track name. I thought of a couple of other scripts:

  • A /google script that creates a list of the top 10/5/1 google hits for a search. (It would be too easy to just have it create a link to google - try about 10 seconds!)
  • A script that defines a word, using or something similar. (Extract from wikipedia?)
  • A script that sends the current playing track to the user. (No need to zip it like some fool did, unless it’s an AIFF file!)
  • A script that displays an html element abbr or acronym.

Using /commands in Adium

I had a thought as to why it might not be a good idea to use /commands, instead of %_commands in Adium. If the text you type is part of a URL, then it will be replaced by the substituted text. For instance, would be replaced by http:/♫ The Chemical Brothers (Feat. The Flaming Lips) • The Golden, which is probably not desired behaviour. I’m not sure if this is a big enough deal for me to stop using them. I did also note that an afp:// had a smiley inserted into it instead… Update: You can add the following to the Info.plist:

1                <key>Prefix Only</key>
2                <true/>

Where the keyword appears. This will mean that the tag must be at the start of a ‘word’ for it work. Thanks, Reikon!

Adium iTunes Rater

I wrote a quick AdiumScript to rate the currently playing song in iTunes. Trivial. The only downside? Arguments to AdiumScripts need to be typed in using {} rather than (). I’m much faster at typing in () without looking at the keyboard than {}. I guess I’ll have to learn. There are also scripts for quick-rating a track as 0-5 stars: /rate3 will rate a track as ★★★. (That’s three stars if you don’t have Unicode!) /rate{44} will set a rating of two-and-a-bit stars. The AdiumScript bundle includes all of the scripts, and can be downloaded Adium Xtras: Rate Current iTunes Track.

Adium Multi Chat

I had to fix a couple of things in my Adium Scripts tonight: I figured out that if you are a chat with more than one person (like in a Jabber ‘room’), and you use serviceClass of contact of the active chat of the first interface controller you will get a list of items, not just one. Actually, you always get a list, just usually it’s only one item long. So, to test if the chat serviceClass is in a set that can handle HTML in chats, you need to use first item of serviceClass... instead of just serviceClass... Note that this returns correct values, wheras serviceClass of chat 1 (where it is a group chat) will return an empty string. Bad coding, Adium. Anyway, I’ve fixed /who to work with multi-person chats, too.