开发者

Adium Applescript Growl Notification

I am writing a script that 开发者_JAVA技巧is initiated every time a contact signs on to Adium. My goal is for a growl message to appear when certain friends log on. Everything works except I do not know how to get the "display name" from the contact that just signed in.

Here is the code:

tell application "Adium"

#Get the alias of the contact that just signed on:
get display name of contact #most recently signed in (HOW DO I RESPRESENT THIS)


#Jon
if display name of contact is "Jon" then

    tell application "GrowlHelperApp"
        -- Make a list of all notification types:
        set the allNotificationsList to ¬
            {"Jon"}

        -- Make a list of the default enabled notifications:
        set the enabledNotificationsList to ¬
            {"Jon"}

        -- Register the script with Growl
        register as application ¬
            "AdiumFriends" all notifications allNotificationsList ¬
            default notifications enabledNotificationsList ¬
            icon of application "AdiumFriends"

        -- Send a notification:
        notify with name ¬
            "Jon" title ¬
            "Jon signed on" description ¬
            ¬
                "Facebook" application name "AdiumFriends"

    end tell
end if

end tell


but you can start a script when a contact logged in. That script could check the name and if it matches with your desired it'll give you a shout


There doesn't appear to be an event to hook into when somebody signs in. Actually, Adium has no events exposed to appleScript at all. If you need this functionality now, you'll probably have to maintain a list of members-signed-in, and then poll regularly. If a new nick appears, that would be the one to growl about. This is not too hard, but regular polling requires an appleScript app which can run in the background, and an idle event, which is not what you want to hear, I am sure.

Sorry not to have better news, but it is a rather typical problem with appleScript: You are at the mercy of the 3rd party app developers to include useful stuff in the dictionary. All too often they don't, but just be thankful there is a dictionary at all!

The slightly better news is this: Both Adium and Growl already have appleScript dictionaries, and both are open source. (Adium is GPL, Growl is BSD). That means that there's a chance you can influence the developers to implement some event handlers for Adium, but also that you can't command a deadline. Have you tried joining the Adium developer forums?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜