Advertisement
Guest User

iChat+

a guest
Feb 11th, 2012
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. property onlineBuddies : 0
  2. using terms from application "iChat"
  3.    
  4.     on received text invitation theMessage from theBuddy for theChat
  5.         accept theChat
  6.         my registerWithGrowl()
  7.         tell application "iChat"
  8.             set theIcon to theBuddy's image
  9.             set theName to theBuddy's full name
  10.         end tell
  11.         my growlNotify(theName, theMessage, theIcon, "Message Received")
  12.     end received text invitation
  13.    
  14.     on message received theMessage from theBuddy for theChat
  15.         my registerWithGrowl()
  16.         tell application "iChat"
  17.             set theIcon to theBuddy's image
  18.             set theName to theBuddy's full name
  19.         end tell
  20.         my growlNotify(theName, theMessage, theIcon, "Message Received")
  21.     end message received
  22.    
  23.     on buddy became available theBuddy
  24.         if window "iChat Buddies" of application "iChat" is visible then
  25.             delay 0.4
  26.             if zoomed of window "iChat Buddies" of application "iChat" is false then
  27.                 set prezoomedWindowBounds to bounds of window "iChat Buddies" of application "iChat"
  28.                 set zoomed of window "iChat Buddies" of application "iChat" to true
  29.                 set postzoomedWindowBounds to bounds of window "iChat Buddies" of application "iChat"
  30.                 if (the bounds of window "iChat Buddies" of application "iChat" is not equal to {item 1 of prezoomedWindowBounds, item 2 of prezoomedWindowBounds, item 3 of prezoomedWindowBounds, item 4 of postzoomedWindowBounds}) then
  31.                     set bounds of window "iChat Buddies" of application "iChat" to {item 1 of prezoomedWindowBounds, item 2 of prezoomedWindowBounds, item 3 of prezoomedWindowBounds, item 4 of postzoomedWindowBounds}
  32.                 end if
  33.             end if
  34.         end if
  35.     end buddy became available
  36.    
  37.     on buddy became unavailable theBuddy
  38.         if window "iChat Buddies" of application "iChat" is visible then
  39.             delay 2.2
  40.             if zoomed of window "iChat Buddies" of application "iChat" is false then
  41.                 set prezoomedWindowBounds to bounds of window "iChat Buddies" of application "iChat"
  42.                 set zoomed of window "iChat Buddies" of application "iChat" to true
  43.                 set postzoomedWindowBounds to bounds of window "iChat Buddies" of application "iChat"
  44.                 if (the bounds of window "iChat Buddies" of application "iChat" is not equal to {item 1 of prezoomedWindowBounds, item 2 of prezoomedWindowBounds, item 3 of prezoomedWindowBounds, item 4 of postzoomedWindowBounds}) then
  45.                     set bounds of window "iChat Buddies" of application "iChat" to {item 1 of prezoomedWindowBounds, item 2 of prezoomedWindowBounds, item 3 of prezoomedWindowBounds, item 4 of postzoomedWindowBounds}
  46.                 end if
  47.             end if
  48.         end if
  49.     end buddy became unavailable
  50.    
  51.     on login finished
  52.     end login finished
  53.    
  54.     on logout finished
  55.     end logout finished
  56.    
  57. end using terms from
  58.  
  59. on registerWithGrowl()
  60.     tell application "System Events"
  61.         set growlIsRunning to ¬
  62.             (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0
  63.     end tell
  64.     if growlIsRunning then
  65.         tell application id "com.Growl.GrowlHelperApp"
  66.            
  67.             set the allNotificationsList to ¬
  68.                 {"Message Received"}
  69.            
  70.             set the enabledNotificationsList to allNotificationsList
  71.             (*set the enabledNotificationsList to ¬
  72.                 {"Message Received"}*)
  73.            
  74.             register as application ¬
  75.                 "iChat" all notifications allNotificationsList ¬
  76.                 default notifications enabledNotificationsList ¬
  77.                 icon of application "iChat"
  78.            
  79.         end tell
  80.     end if
  81. end registerWithGrowl
  82.  
  83. on growlNotify(eventTitle, eventDescription, eventImage, eventName)
  84.     tell application "System Events"
  85.         set growlIsRunning to ¬
  86.             (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0
  87.     end tell
  88.     if growlIsRunning then
  89.         tell application id "com.Growl.GrowlHelperApp"
  90.             if eventImage is "" or eventImage is missing value then
  91.                 notify with name ¬
  92.                     eventName title ¬
  93.                     eventTitle description ¬
  94.                     eventDescription application name ¬
  95.                     "iChat" icon of application "iChat"
  96.             else
  97.                 notify with name ¬
  98.                     eventName title ¬
  99.                     eventTitle description ¬
  100.                     eventDescription application name ¬
  101.                     "iChat" image eventImage
  102.             end if
  103.         end tell
  104.     end if
  105. end growlNotify
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement