Advertisement
flypip

FlySkype(GeekTool)

Jul 9th, 2012
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. on JoinList(l, del)
  2.     set RetVal to ""
  3.     set OldDel to AppleScript's text item delimiters
  4.     set AppleScript's text item delimiters to del
  5.     set RetVal to l as string
  6.     set AppleScript's text item delimiters to OldDel
  7.     return RetVal
  8. end JoinList
  9.  
  10. on SplitList(t, del)
  11.     set RetVal to {}
  12.     set OldDel to AppleScript's text item delimiters
  13.     set AppleScript's text item delimiters to del
  14.     set RetVal to every text item of t
  15.     set AppleScript's text item delimiters to OldDel
  16.     return RetVal
  17. end SplitList
  18.  
  19. on ReplaceString(theText, oldString, newString)
  20.     set OldDel to AppleScript's text item delimiters
  21.     set AppleScript's text item delimiters to oldString
  22.     set tempList to every text item of theText
  23.     set AppleScript's text item delimiters to newString
  24.     set theText to the tempList as string
  25.     set AppleScript's text item delimiters to OldDel
  26.     return theText
  27. end ReplaceString
  28.  
  29. set OnlineFriends to {}
  30. tell application "System Events"
  31.     set powerCheck to ((application processes whose (name is equal to "Skype")) count)
  32.    
  33.     if powerCheck = 0 then
  34.         set end of OnlineFriends to "Skype is not running."
  35.     else
  36.         tell application "Skype"
  37.             set SkypeStatus to send command "GET CONNSTATUS" script name "online users"
  38.             if SkypeStatus is "CONNSTATUS ONLINE" then
  39.                 set AppleScript's text item delimiters to " "
  40.                 set Friends to send command "SEARCH FRIENDS" script name "online users"
  41.                 set Friends to my ReplaceString(Friends, " ", ",")
  42.                 set Friends to my ReplaceString(Friends, ",,", ",")
  43.                 set FriendsList to my SplitList(Friends, ",")
  44.                 set NumFriends to number of items in FriendsList
  45.                 repeat with i in FriendsList
  46.                     if (i begins with "DISABLEDxmpp:") or (i begins with "USERS") or (i is "echo123") then
  47.                         --ignore these
  48.                     else
  49.                         -- Determine online status and get details only for online friends
  50.                         set FriendStatus to send command "GET USER " & i & " ONLINESTATUS" script name "online users"
  51.                         if text item 4 of FriendStatus is "ONLINE" then
  52.                             set aUser to send command "GET USER " & i & " FULLNAME" script name "online users"
  53.                             set aUser to text items 4 thru end of aUser
  54.                             set aUser to my JoinList(aUser, " ")
  55.                             if aUser is "" then set aUser to i
  56.                             set amoodtext to send command "GET USER " & i & " MOOD_TEXT" script name "online users"
  57.                             if number of text items in amoodtext > 3 then
  58.                                 set amoodtext to text items 4 thru end of amoodtext
  59.                                 set amoodtext to my JoinList(amoodtext, " ")
  60.                                 if amoodtext is "" then
  61.                                     set end of OnlineFriends to aUser
  62.                                 else
  63.                                     set end of OnlineFriends to aUser & " (" & amoodtext & ")"
  64.                                 end if
  65.                             end if
  66.                         end if
  67.                     end if
  68.                 end repeat
  69.                 if (count OnlineFriends) > 0 then
  70.                     set OnlineFriends to my JoinList({"Skype Friends:"} & OnlineFriends, "
  71. ")
  72.                 else
  73.                     set beginning of OnlineFriends to "No Skype Friends online at this time."
  74.                 end if
  75.             else
  76.                 set beginning of OnlineFriends to "Skype is offline."
  77.             end if
  78.         end tell
  79.     end if
  80. end tell
  81. return OnlineFriends
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement