• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
re: iChat, Leopard and determining if a buddy has a chat- SOLVED
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: iChat, Leopard and determining if a buddy has a chat- SOLVED


  • Subject: re: iChat, Leopard and determining if a buddy has a chat- SOLVED
  • From: broz <email@hidden>
  • Date: Sat, 17 Nov 2007 21:10:04 -0500
  • Thread-topic: iChat, Leopard and determining if a buddy has a chat- SOLVED

I've got it figured.

To recap:

Using iChat in Leopard, I want to sent a message to a buddy periodically. A
chat with that buddy might already exist, and it might not.

If I execute the script and a chat doesn't exits already, it creates a chat
and sends the message. That's good.

If I execute the script and the chat already exists, iChat complains, saying
a chat with that buddy already exists and that I should use that existing
chat.

I created a subroutine to determine that. Note that this routine did not
work before the recent 10.5.1 update. It does now.

Note that this routine has barely, barely been tested.

on getChat(theBuddy, theService)
    (*
    in order to send messages to a buddy periodically, one
    needs to know if a chat already exists for this buddy.
    if it does, use it. if not, create one.
    this function returns an existing chat, or creates a
    new one based on the above
    *)
    set returnedChat to ""
    set chatList to {}
    tell application "iChat"
        set chatList to every text chat
        repeat with i in chatList
            try

                if every chat of the services of theBuddy exists then
                    repeat with thechat in every chat of service of theBuddy
                        if (id of thechat as text) is (id of i as text) then
                            set returnedChat to i
                            exit repeat
                        end if
                    end repeat -- every chat of theBuddy
                end if

            on error theError number theNumber
                display dialog (theError as text) & theNumber as text
            end try
        end repeat -- chatList
        if returnedChat is "" then
            make new text chat ¬
                with properties {participants:{theBuddy},
service:theService}
            set returnedChat to result
        end if

    end tell
    return returnedChat
end getChat


--

Richard Brosnahan
Editor in Chief
Broz News
http://broznews.org

A pessimist sees the difficulty in every opportunity; an optimist sees the
opportunity in every difficulty.

Sir Winston Churchill, statesman






 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: cross-platform problem, possible applescript solution?
  • Next by Date: Time format
  • Previous by thread: Re: cross-platform problem, possible applescript solution?
  • Next by thread: Time format
  • Index(es):
    • Date
    • Thread