Skip to content

Instantly share code, notes, and snippets.

@cockscomb
Created October 4, 2011 11:02
Show Gist options
  • Save cockscomb/1261357 to your computer and use it in GitHub Desktop.
Save cockscomb/1261357 to your computer and use it in GitHub Desktop.
Growl when new message arrived.
using terms from application "iChat"
on message received this_message from this_buddy for this_chat
(*EXAMPLE: this routine automatically sends a random response to messages from specified buddies
set this_name to the name of this_buddy
if the name of this_buddy is in {"Johnny Appleseed"} then
set canned_responses to {"Oh, I know!", "I was just thinking about that.", "Maybe tomorrow.", "Seems logical."}
set this_response to some item of the canned_responses
send this_response to this_chat
end if
*)
set this_name to the name of this_buddy
set this_image to the image of this_buddy
try
set this_subject to the subject of this_chat
if this_subject is missing value then error
on error
set this_subject to "NO SUBJECT"
end try
-- display Growl notification
tell application "Growl"
set allNotificationsList to {"New Message"}
set enableNotificationsList to {"New Message"}
register as application "iChat" all notifications allNotificationsList default notifications enableNotificationsList
if this_image is not missing value then
notify with name "New Message" title (this_name & " — " & this_subject) description this_message application name "iChat" image this_image callback URL "ichat:"
else
notify with name "New Message" title (this_name & " — " & this_subject) description this_message application name "iChat" callback URL "ichat:"
end if
end tell
end message received
end using terms from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment