-
-
Save dekz/1856934 to your computer and use it in GitHub Desktop.
iChat / Messages integration for Growl 1.3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- growl notifications for iChat, based on | |
-- http://scriptingosx.com/2010/11/ichat-notification-with-growl/ | |
property growlAppName : "Growl iChat" | |
property notificationNames : {"Buddy Became Available", ¬ | |
"Buddy Became Unavailable", ¬ | |
"Message Received", ¬ | |
"Completed File Transfer"} | |
property defaultNotificationNames : {"Buddy Became Available", ¬ | |
"Buddy Became Unavailable", ¬ | |
"Message Received", ¬ | |
"Completed File Transfer"} | |
using terms from application "iChat" | |
on buddy became available theBuddy | |
my registerWithGrowl() | |
tell application "iChat" | |
tell theBuddy | |
set theTitle to full name & " became available" | |
set theDesc to status message | |
set theIcon to image | |
end tell | |
end tell | |
my notify(theTitle, theDesc, theIcon, "Buddy Became Available") | |
end buddy became available | |
on buddy became unavailable theBuddy | |
my registerWithGrowl() | |
tell application "iChat" | |
tell theBuddy | |
set theTitle to full name & " went away" | |
set theDesc to status message | |
set theIcon to image | |
end tell | |
end tell | |
my notify(theTitle, theDesc, theIcon, "Buddy Became Unavailable") | |
end buddy became unavailable | |
on message received theText from theBuddy for theTextChat | |
if my isBackground() then | |
my registerWithGrowl() | |
tell application "iChat" | |
set theIcon to image of theBuddy | |
set theTitle to full name of theBuddy | |
end tell | |
my notify(theTitle, theText, theIcon, "Message Received") | |
end if | |
end message received | |
on completed file transfer theTransfer | |
my registerWithGrowl() | |
tell application "iChat" | |
tell theTransfer | |
if transfer status is finished then | |
if direction is incoming then | |
set theTitle to "Received File " | |
set theDesc to "from " | |
else | |
set theTitle to "Sent File " | |
set theDesc to "to " | |
end if | |
set theTitle to theTitle & (file as string) | |
set theDesc to theDesc & full name of buddy | |
end if | |
end tell | |
end tell | |
my notify(theTitle, theDesc, theIcon, "Message Received") | |
end completed file transfer | |
end using terms from | |
on registerWithGrowl() | |
tell application "Growl" | |
register as application growlAppName all notifications notificationNames default notifications notificationNames icon of application "iChat" | |
end tell | |
end registerWithGrowl | |
on notify(theTitle, desc, icondata, notificationName) | |
tell application "Growl" | |
if icondata is "" or icondata is missing value then | |
notify with name notificationName title theTitle description desc application name growlAppName icon of application "iChat" | |
else | |
notify with name notificationName title theTitle description desc application name growlAppName image icondata | |
end if | |
end tell | |
end notify | |
on isBackground() | |
tell application "System Events" to (name of first application process whose frontmost is true) is not "iChat" | |
end isBackground |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment