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:

    <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>
    

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.

Chatting to Robots?

I had a thought just before. (Unusual, I know). I wrote a program called iTunesRater so I can rate my music as I listen to it in iTunes, and then went on to write a series of Adium Scripts to control iTunes ratings, and get data from iTunes.

What if instead of having to create scripts for iTunes that did everything you want, you just create a bot that runs, and you send messages to it, and it controls iTunes. So, I could have the program running, and instead of having to type: /itunes

_♫ The Chemical Brothers (Feat. The Flaming Lips) • The Golden Path _

/rate{44} /itunes

♫ The Chemical Brothers (Feat. The Flaming Lips) • The Golden Path ★★

I could just start up a chat with iTunes, and type all sorts of commands:

me: song

it: ♫ The Chemical Brothers (Feat. The Flaming Lips) • The Golden Path

me: rate 44

it: ♫ The Chemical Brothers (Feat. The Flaming Lips) • The Golden Path ★★

me: next track

[iTunes next track plays]

All it would seem to require is a program that can connect to a server of some sort (I think maybe Jabber, then I can run my own Jabber server!), and sends AppleScript messages to iTunes. Or any other application, for that matter.

Camino Coloured Tab

I opened this page in Camino, and found that the tab coloured itself blue: Weird. I wonder if its a controllable thing, or a bug? Edit: Must be a bug, as opening a new page in the same tab kept the tab blue, and closing the tab and re-opening the same page didn’t result in that tab going blue. Strange.

Smelly Flower

As I checked the mailbox when getting home tonight, I noticed a lovely purple Arum-like flower growing just near: Smelly Arum Lily After picking it, I noticed that it was rather smelly. In fact, it smells like a dead sheep, or something like that!

Livien - Journal of Jennifer Sando » Fearing August

Livien – Journal of Jennifer Sando » Fearing August

This weekend, I am going to see La Boheme. I haven’t been to see an opera in more than 5 years now – the last time was when I lived in Brisbane and it was La Traviata. I went with my family and we were all dressed up ‘to the nines’. (Geez, I hate using over-done phrases like the one you just read – but my friend said it to me earlier and now it’s just stuck there). I remember being stunned that the Queenslanders tended to see it more as a casual occasion.

I recall the first time I went to Queensland on a holiday being surprised at the patrons in the Casino not wearing ‘nice’ clothes. That is, they were in shorts, tee-shirts and thongs. This was in the Gold Coast though…

Page Visit Dropoff

I don’t obsess over my referers, much. It’s interesting to see what pages people have visited, and where they have come from, but I don’t write the stuff on this site because I’m trying to make myself heard, or popular. It’s more of: “Here’s some information I’ve come across: if someone else is searching for it and I can help them, that’s all good!” Having said that, I have had days in the last month or so where I have had over 400 page visits. Many of those are to the one post I wrote on Sudoku, ages ago, but they still keep coming. Even though I don’t actually provide much information in that post! I even had a day, a month ago, that had 690 referers, although a big chunk of them were actually some spider, as they were all DIRECT referers, and all seemed to be accessing weird URLs. More recently, I’ve discovered the Gvisit page, and have been able to see my most recent visitors locations, on a Google Map, which is very cool. I’ve even thought of making a category link, a home page link, and so on. But that seems like it might be too much work. Today, I noticed I only had 24 referers at around 2:30 (ACST: +0930), a time I usually number around 150. I thought, “Hey, there’s something weird going on here!”, and looked at the monthly view. 125 yesterday, and 174 the previous. Prior to that, each day had around 3-400 referers. I’m not sure why my traffic has suddenly halved: my Google Page Rank is a fair 5/10 (Boing Boing has a Page Rank of 8, Blogsome 6)

Even better Current iTunes Track

It’s nice to show other users what you are listening to, and provide a handy link for them to see more about the artist and track. I noticed that some IM systems don’t like HTML, and I figured out a way to make the link only be sent to a user of an AIM compatible or Jabber server.

Basically, you test the result of serviceClass of contact of the active chat of the first interface controller, and if it is “AIM-compatible” or “Jabber”, then you use HTML, if not, just plain text. You can download it from Adium Xtras: Now Playing in iTunes.

Full Source:

 1  Better itunes adium link script
 2  Includes rating (if present), and links.
 3 property message_prefix : «data utxt266B0020» as Unicode text
 4 property not_listening_message : "Quiet"
 5 property star : «data utxt2605» as Unicode text
 6 property google : "http://www.google.com/search?q="
 7 property server : ""
 8 
 9 property html_classes : {"AIM-compatible", "Jabber"}
10 
11 on substitute()
12     set server to "http://" & my getIP() & ":8080"  Use betterGetIP if on broadband!
13     
14     tell application "System Events"
15         try
16             get process "iTunes"
17         on error
18             return message_prefix & not_listening_message
19         end try
20     end tell
21     
22     tell application "iTunes"
23         if player state is not playing then
24             return message_prefix & not_listening_message
25         end if
26         set theArtist to artist of current track
27         if theArtist is "" then set theArtist to "Unknown Artist"
28         set theTrack to name of current track
29         set theRating to " " & my myRating(rating of current track)
30         set theLocation to location of current track
31         set pth to my encode_URL_string(characters 9 thru end of (POSIX path of theLocation) as string)
32     end tell
33     
34     tell application "Adium" to set accountType to serviceClass of contact of the active chat of the first interface controller
35     if first item of accountType is in html_classes then
36         return html(message_prefix & my myLink(google, theArtist) & " • " & my myLink(server & pth, theTrack) & theRating)
37     else
38         return message_prefix & theArtist & " • " & theTrack & theRating
39     end if
40 end substitute
41 
42 on myRating(theRating)
43     set theResult to ""
44     set theTimes to (theRating - 9) / 20 as integer
45     repeat theTimes times
46         set theResult to theResult & star
47     end repeat
48     return theResult
49 end myRating
50 
51 on myLink(URI, theText)
52     if URI is google then
53         set URI to URI & first word of theText
54         repeat with wd in (rest of every word of theText)
55             set URI to URI & "+" & wd
56         end repeat
57     else if server is "" then
58         return theText
59     end if
60     return "<a href=\"" & URI & "\">" & theText & "</a>"
61 end myLink
62 
63 on html(str)
64     return ("<HTML>" as Unicode text) & str & "</HTML>"
65 end html
66 
67 on getIP()
68     return do shell script "ifconfig ppp0 | grep inet | awk ‘{print $2}’"
69 end getIP
70 
71 on betterGetIP()
72     return do shell script "curl -s http://www.showmyip.com/simple/ | grep GMT | awk ‘{print $1}’"
73 end betterGetIP
74 
75 property allowed_URL_chars : (characters of "/$-_.+!*’(),1234567890abcdefghijklmnopqrstuvwxyz")
76 property hex_list : (characters of "0123456789ABCDEF")
77 
78 on encode_URL_string(this_item)
79     set character_list to (characters of this_item)
80     repeat with i from 1 to number of items in character_list
81         set this_char to item i of character_list
82         if this_char is not in allowed_URL_chars then set item i of character_list to my encode_URL_char(this_char)
83     end repeat
84     return character_list as string
85 end encode_URL_string
86 
87 on encode_URL_char(this_char)
88     set ASCII_num to (ASCII number this_char)
89     return ("%" & (item ((ASCII_num div 16) + 1) of hex_list) & (item ((ASCII_num mod 16) + 1) of hex_list)) as string
90 end encode_URL_char
91 
92 on run
93     tell application "Adium" to activate
94     my substitute()
95 end run

Getting the Active Chat in Adium

Getting the active chat in Adium from AppleScript appears at first look to be a little dicey: Adium needs to actually be the active application before the code actually works! For instance, if you open up the Script Editor, and type in the following:

tell application “Adium”     get contact of the active chat of the first interface controller end tell

You will get an empty list: {} To get a result, all you need to include is:

    activate

just before you access something belonging to the active chat. If you are creating an AdiumScript, and are testing it in the Script Editor, chances are you have used the idiom:

on run     my substitute() end run

To get this to work if you are using the active chat, it just needs to be changed to:

on run     tell application “Adium” to activate     my substitute() end run

Happy AdiumScripting!

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.