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: your.account@gmail.com Password: •••••••• Connect Server: talk.google.com 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.

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

Python Scripts inside AdiumScripts package

I’ve got some stuff to do that will be easier with python, so I’m wondering if it’s possible to package a python script up, and use it from within an AppleScript, without having to have it in the path. It may not be, since AppleScript’s

do shell script “pwd”

returns "/", indicating it is running at the root directory. Well, back to pipes and awk/sed. (Actually, I think I’d just used awk & sed inside the python script).

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 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 dictionary.org 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.

Adium Plugin Scripts

Adium has great support for AppleScripts (or possibly other scripting languages), in that you define a string, and when this string is typed in as a message, the script is run, and the result is sent as the message instead. Thus, it’s possible to write scripts that allow you to type in: %_itunes And a nicely formatted string, with the current iTunes song is sent to the person you are chatting to. This string can even have hyperlinks embedded in it, so if you were serving your iTunes library up, the person could click on it and download/stream it. The same for %_safari/%_camino, this can be set up to send a hyperlink with the current page, including the title. What is not clear from the internet is how to create these. It’s really quite simple. The scripts must live inside a package: under MacOS X packages are just folders with particular extensions. For instance, Mail.app is a folder, and it appears to the system/user as an application, or a particular type of package. Double-clicking on it will not opent he folder, but (in this case) run the application. AdiumScripts packages (with the extension .AdiumScripts) will install into your Library when you double-click them. So, the format must be as follows:

PluginName.AdiumScripts/
    Contents/
        Info.plist
        Resources/
            Script1Name.scpt
            Script2Name.scpt

The ScriptxName.scpt files must be valid AppleScripts, of the format:

on substitute(arg) –do stuff here return value end substitute

Where value is the value you want printed. You should format it with starting and closing html tags, and any html markup you want. If you want the user to be able to send an argument (%command{argument}), then include it as shown. Inside the Info.plist file, you need to have some important information.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>CFBundleDevelopmentRegion</key>
        <string>English</string>
        <key>CFBundleGetInfoString</key>
        <string>Matt's Adium Scripts</string>
        <key>CFBundleIdentifier</key>
        <string>net.schinckel.AppName.scripts</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>1.0</string>
        <key>CFBundleName</key>
        <string>bundleName</string>
        <key>CFBundlePackageType</key>
        <string>AdIM</string>
        <key>Scripts</key>
        <array>
            <dict>
                <key>File</key>
                <string>Script1Name</string>
                <key>Keyword</key>
                <string>/script1</string>
                <key>Title</key>
                <string>Menu Item 1</string>
            </dict>
            <dict>
                <key>File</key>
                <string>Script2Name</string>
                <key>Keyword</key>
                <string>%_script2</string>
                <key>Title</key>
                <string>Menu Item 2</string>
            </dict> </array>
        <key>Set</key>
        <string>Script Submenu</string>
    </dict>
    </plist>

There are some bits of data you’ll need to change: Matt's Adium Scripts should be a descriptive title for your Scripts. com.schinckel.AppName.scripts should be a unique identifier for your scripts. bundleName could be the name of your bundle. Realistically, these can be anything, although I suspect Adium will only allow one version of a script with a particular identifier, or bundle name. The next bits are the impart ones: Script1Name needs to be the name of a script, minus the .scpt extension. /script1 is the keyword that will trigger this script to be called. And Menu Item 1 is what will be written in the Scripts Sub Menu. It’s possible to have multiple calls to the same script, each one just requires a duplicate dictionary entry, with a different Keyword string. For instance, I use /camino and %_camino to mean the same function, without requiring seperate scripts to be called. Finally, the Script Submenu value needs to be replaced by which Script Sub Menu you want the item to be placed under. For instance, there is already one called System Statistics, and iTunes - Now Playing. Using a value that doesn’t appear already causes a new Sub Menu to be created. I’m not sure if there is a ‘rule’ against using /command, as most of the ones I’ve come across all use %_command. I find this too slow to type, and have adapted them accordingly. You will be able to do this also, now that you know how…

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!

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