iChat, Leopard and determining if a buddy has a chat
iChat, Leopard and determining if a buddy has a chat
- Subject: iChat, Leopard and determining if a buddy has a chat
- From: Richard Brosnahan <email@hidden>
- Date: Sun, 11 Nov 2007 21:19:34 -0500
- Thread-topic: iChat, Leopard and determining if a buddy has a chat
I've got a script that almost works.
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'd love to.
I created a subroutine to determine that, but Applescript returns an error
that I consider pretty stupid, or at least cryptic.
I loop thru every chat to find the list of participants in each, and then
thru the participants to find the buddy.
The error is
"can't make buddy id of theParticipant into a type specifier"
I tried comparing handles but AppleScript says it can't make the handle into
text.
So I can't compare values and can't convert the values to strings and
compare them.
Frustrating.
I wonder if anyone here can provide some insight.
TIA
on getChat(theBuddy, theService)
(*
determine if a chat exists for a buddy
if not, then create a new chat
*)
set returnedChat to ""
set chatList to {}
tell application "iChat"
set chatList to every chat
repeat with i in chatList
try
set theParticipants to participants of i
if the participants of i is not missing value then
repeat with theParticipant in participants of i
-- each of these participants is
-- an array of buddy ids
-- the buddy id of theParticipant
-- is something like {buddy id "737236823428421823681"}
-- I get an error saying applescript
-- can't make buddy id of theParticipant
-- into a type specifier. wha...?
-- looks like a bug in AS in Leopard?
if id of theBuddy is buddy id of theParticipant then
set returnedChat to i
exit repeat -- inner loop
end if
end repeat -- participants
end if
on error theError
display dialog theError 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
Owner
Engineering Art, L.L.C
email@hidden
M 804.304.6880
The indispensable first step to getting the things you
want out of life is this: Decide what you want.
Ben Stein, lawyer, writer, teacher
_______________________________________________
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