Page 1 of 1

quicksilver + applescript question

Posted: Tue Jun 03, 2008 10:45 pm
by dkocolin
Hey all,

I'm currently using the following AppleScript with QuickSilver

Code: Select all

using terms from application "Quicksilver"
	on process text ThisClipping
		
		tell application "Adium"
			set the status type of every account to away
			set the status message of every account to ThisClipping
		end tell
		
	end process text
end using terms from
However, while this does set status it doesn't set autoreply.

I've tried adding

Code: Select all

set the status autoreply of every account to ThisClipping
but it doesn't seem to have much of an effect.

Any suggestions? Also, is there a script for Quicksilver to send a message to someone? I tried one from 2006 but it doesn't seem to work any longer.

Re: quicksilver + applescript question

Posted: Thu Jun 05, 2008 4:44 am
by mtimmsj
Autoreply is a read only property of the status objects, not account objects. So you can't set it in the way you are trying to. Accounts only allow for temporary status settings of "status type" and "status message."

More info here: http://trac.adiumx.com/wiki/AppleScript_Support_1.2

The only way to set an autoreply is to first create a status with the make new command and include the autoreply property:

Code: Select all

tell application "Adium"
  make new status with properties {status type:away, title:"I'm not here", message:"I'm not here", autoreply:"Your message will be read when I return"}
end tell
Then set the current status to the newly made status.

The make new command is broken in Leopard (10.5): http://trac.adiumx.com/ticket/8863

I believe it's been reported to be functional in Tiger (10.4).

One way around the problem is to wrap the make new command into a try block because even though the make new command errors out, the status is still created:

Code: Select all

tell application "Adium"
try
  make new status with properties {status type:away, title:"I'm not here", message:"I'm not here", autoreply:"Your message will be read when I return"}
on error
  set status of the first account to the first status whose title is "I'm not here"
end try
end tell
When I tested this though, the autoreply didn't seem to get filled in properly. It set the "autoreply" flag, but the custom autoreply message didn't get populated. I'm testing on 1.3svn though. The results may be different with 1.2.5.

Sending a message in Adium first requires a chat be opened with the contact because you can only send a message to a chat, not to the contact. So you must first make a chat with the contact, once the chat is made you can send a message to the chat. So the generic method of sending a message to a contact would be:

Code: Select all

tell application "Adium"
	tell account "accountname" to set myChat to make new chat with contacts {contact "contactname"} with new chat window
	send myChat message "test"
end tell
It only opens a new chat if one is not already open.

A word of caution, the contact *MUST* exist, or you run into another bug which causes very odd behavior with windows: http://trac.adiumx.com/ticket/8864

Using these examples it should be possible for you to come up with a solution (hopefully). Once you have a solution it would be good if you posted it in the forum so others can benefit from it.