[HELP REQ] AppleScript to tell Adium to go away

An instant messenger which can connect to AIM, GTalk, Jabber, ICQ, and more.
Post Reply
User avatar
MordEth
Harmless
Posts: 10
Joined: Wed Dec 29, 2004 12:56 am
Location: somewhere north of Hades
Contact:

[HELP REQ] AppleScript to tell Adium to go away

Post by MordEth »

If anyone can help me with this, I'd appreciate it greatly.

I'm trying to write a script to have Adium go away if i send myself (from another screen name) a message saying "go away". (i.e. when I forget to go away before leaving my apartment.) Unfortunately, I'm not very good with Applescript, and am having trouble getting this to work.

What I have right now:

Code: Select all

tell application "Adium"
	if (get content plainText message) = "go away" then
		set my status message to "leave a message."
		set my status type to away
	end if
end tell
I have Adium calling this script on any message received from my other user, but so far i cannot get it to only work when i send "go away", and not when I send any mesage (i.e. removing the if statement works).

On a somewhat related matter...is there any way to have Adium select a pre-defined status message? Ideally, rather than picking an away status, it'd be preferred if I can tell myself which of my preset status messages to use.

One final thing, which I think may be a bug...if I remove the if statement, and manage to send myself away with that script, it looks like this:

Image

(Note that b0r3dm0ri is not being handled by Adium, so that account is not showing as away.)

Shouldn't this be changing the color of the status message (at the top of the contacts window) to red, rather than green?

Again...thanks in advance for any assistance.
Ludge
Latté
Posts: 79
Joined: Sat Mar 19, 2005 5:20 pm

Post by Ludge »

I know Evan did a lot of work on applescript recently, but I don't think you can set your status to away properly. Have a search on Trac for applescript status and there might be a sample script or two.
Image
User avatar
Tipo 61
Grandé
Posts: 910
Joined: Fri Dec 10, 2004 11:12 pm
Location: Boston, MA
Contact:

Post by Tipo 61 »

User avatar
MordEth
Harmless
Posts: 10
Joined: Wed Dec 29, 2004 12:56 am
Location: somewhere north of Hades
Contact:

RE: parsing content from a received message

Post by MordEth »

Thanks for the tips. I've looked at a lot of other people's scripts, and that's how I figured out how to send myself away.

Mostly what I'm having a problem figuring out, though, is how to get content received by Adium (a message), so that I can compare it against something ("go away") to have the Applescript do an action.

Anyone have any suggestions on this?

Thanks again for all of your assistance.
User avatar
evands
Cocoaforge Admin
Posts: 3152
Joined: Thu Dec 02, 2004 10:55 pm
Location: Decatur, GA
Contact:

Re: RE: parsing content from a received message

Post by evands »

MordEth wrote:Mostly what I'm having a problem figuring out, though, is how to get content received by Adium (a message), so that I can compare it against something ("go away") to have the Applescript do an action
Never say never, but I'm not aware of support for having applescripts being triggered by anything incoming... Colloquy has great support for extensibility in this way via applescript; perhaps an interested party could apply code from there to Adium.
The duck still burns.
--
My company: Saltatory Software. Check it out :)
User avatar
MordEth
Harmless
Posts: 10
Joined: Wed Dec 29, 2004 12:56 am
Location: somewhere north of Hades
Contact:

Re: RE: parsing content from a received message

Post by MordEth »

evands wrote:Never say never, but I'm not aware of support for having applescripts being triggered by anything incoming... Colloquy has great support for extensibility in this way via applescript; perhaps an interested party could apply code from there to Adium.
Hrm. I was thinking that since scripts could be triggered off of the receipt of a message by a particular user (which is what I'm doing now), it might be possible to use Applescript to get the content of that mesage from Adium. (note: I'm not all that great at Applescript, though.)

Although after reading your message, I did think of something that I could do, even if it's kind of kludge. this works reasonably well:

Code: Select all

tell application "Adium"
	set LastMessage to (do shell script "cd "/Users/mordeth/Library/Application Support/Adium 2.0/Users/Default/Logs/AIM.kuraakudeibiddo/b0r3dm0ri"; tail -n1 "`ls -x1 | tail -n1`"")
	
	if LastMessage contains "go away" then
		set my status message to "leave a message."
		set my status type to away
	end if
end tell
There's probably a better way to have Applescript read the last line of the newest file in a directory, but i know shell scripting far better than I know Applescript.

Thanks again for everyone's comments and assistance. If anyone finds a better method to do this (or pick a preset away status), let me know. ^_^
Post Reply