Messages: show notification when buddy becomes available


macrumors regular
Original poster
Jun 20, 2007
One thing I miss from iChat and Growl: the notification showing when one of your friend just connected.

I found 2 scripts: one to send anything to Notification Center and another one to monitor when a Messages contact becomes available but I haven't build able to create a proper Apple Script until now.

Any help?
PS: code NOT mine

using terms from application "Messages"
	on buddy became available theBuddy
		tell application "Messages"
			tell theBuddy
				-- set _service to service type of service of theBuddy
				set _service to "Jabber"
				set _handle to handle of theBuddy
				set grrCURL to "Messages:compose?service=" & _service & "&id=" & _handle & "&style=textchat"
				if _handle contains "google" then
					set _platform to "GTalk"
				else if _handle contains "gmail" then
					set _platform to "GTalk"
					set _platform to "Messages"
				end if
				set grrTitle to full name
				set grrDescription to _platform & "
" & status message
				set grrPriority to 0
				set grrIcon to image
			end tell
		end tell
		growlNotify(grrTitle, grrDescription, grrPriority, grrIcon, grrCURL)
		tell application "Notifications Scripting"
			--  This is required for calling the user notification event handlers. The handlers can be in a different script file.
			set event handler script to ("buddy became available")
			-- The user info parameter is a record. The supported data types are text, integer, real, boolean, date, alias, file and POSIX file.
			set dict to {theName:"Notifications Scripting", theVersion:"1.0", theScript:event handlers script path}
			-- Create a notification. Only the title is required at minimum.
			-- Use "Default" for the default sound played by the user notification center.
			-- See the Notifications Scripting dictionnary for more informations.
			display notification "My title" subtitle grrDescription message "My Message" user info dict
		end tell
	end buddy became available
end using terms from