Messages: show notification when buddy becomes available

Discussion in 'Mac Apps and Mac App Store' started by arnoz, May 13, 2013.

  1. arnoz macrumors regular

    Joined:
    Jun 20, 2007
    Location:
    Lausanne
    #1
    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

    PHP:
    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"
                    
    else
                        
    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
    (grrTitlegrrDescriptiongrrPrioritygrrIcongrrCURL)
            
            
            
    tell application "Notifications Scripting"
                
                
    --  This is required for calling the user notification event handlersThe handlers can be in a different script file.
                
    set event handler script to ("buddy became available")
                
                -- 
    The user info parameter is a recordThe supported data types are textintegerrealbooleandatealiasfile and POSIX file.
                
    set dict to {theName:"Notifications Scripting"theVersion:"1.0"theScript:event handlers script path}
                
                -- 
    Create a notificationOnly 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
     
  2. arnoz thread starter macrumors regular

    Joined:
    Jun 20, 2007
    Location:
    Lausanne
  3. allan.nyholm macrumors 6502a

    allan.nyholm

    Joined:
    Nov 22, 2007
    Location:
    Aalborg, Denmark
  4. arnoz thread starter macrumors regular

    Joined:
    Jun 20, 2007
    Location:
    Lausanne
    #4
    I have seen many scripts like this but I want to use only Notificaiton Center.
     
  5. arnoz thread starter macrumors regular

    Joined:
    Jun 20, 2007
    Location:
    Lausanne
  6. arnoz thread starter macrumors regular

    Joined:
    Jun 20, 2007
    Location:
    Lausanne

Share This Page