Adium

Opened 13 years ago

Closed 12 years ago

Last modified 8 years ago

#8809 closed defect (fixed)

AppleScript to change global status does not work

Reported by: chockenberry Owned by: applmak
Milestone: Adium 1.3 Component: AppleScript
Version: Severity: regression
Keywords: Cc:
Patch Status:

Description

In previous versions of Adium, external applications could update the user's status with an AppleScript like this:

tell application "Adium"

set my status message to "Something new"

end tell

In Adium 1.2, this results in the following error:

Can’t set «class Pasm» to "Something new".

Change History (34)

comment:1 Changed 13 years ago by Carlos Morales

pending: 01
Version: 1.2

I'm not sure if this is a bug, of just the result of a new implementation.

try

tell application "Adium"
	
	go away with message "Something new"
	
end tell

comment:2 Changed 13 years ago by Craig Hockenberry

pending: 10

How would one change just the message with the new implementation? My application does not want to change the user's state, just their message.

Do i need to iterate over each account and get the status type to do this? For example:

tell application "Adium"

status type of status of first account

end tell

comment:3 Changed 13 years ago by Craig Hockenberry

It's also probably a good idea to keep some backward compatibility with the script syntax. There are lots of applications/hacks that use "set my status message to" as an integration point.

comment:4 Changed 13 years ago by Craig Hockenberry

Here is a workaround:

set theMessage to "Something new"

tell application "Adium"
	repeat with theAccount in accounts
		set theStatus to status type of status of theAccount
		
		(*
		set theTitle to title of theAccount
		set theDebugMessage to "Account: " & theTitle & " Status: " & (theStatus as string)
		tell application "Finder" to display dialog theDebugMessage
		*)
		
		if (theStatus is available) then
			go available theAccount with message theMessage
		else if (theStatus is away) then
			go away theAccount with message theMessage
		end if
	end repeat
end tell

Again, I'd highly recommend keeping the previous syntax to maintain compatability with other applications.

Note also that applications using this workaround will NOT be compatible with older versions of Adium.

comment:5 Changed 13 years ago by Jordan

Resolution: invalid
Status: newclosed

The applescript updates may indeed break old scripts - but there are different methods to accomplish the same thing with the new implementation.

comment:6 Changed 13 years ago by Matt Handley

While that workaround code looks like it will work, you should feel free to use the simpler:

tell app "Adium"
  set the status message of some account to "Something New"
end

You can also use the go <status> with message "message" to change the status type and message in one command.

comment:7 Changed 13 years ago by Craig Hockenberry

set the status message of some account to "Something New"

This doesn't work if you have more than one account and the first account is disabled.

comment:8 Changed 13 years ago by Matt Handley

No, I meant you should write something along those lines:

set the status message of account "applmak" to "Do IM me"
set the status message of every account to "Not here"
set the status message of every account whose status type is available to "I'm having a good day"

These are all examples of valid ways of changing the status message for an account.

Also, I think if you try to change the status message of an account that's offline, nothing will happen.

comment:9 Changed 13 years ago by Evan Schoenberg

Resolution: invalid
Status: closedreopened

comment:10 Changed 13 years ago by Evan Schoenberg

Milestone: Adium X 1.2.1
Resolution: fixed
Status: reopenedclosed

I've also added for 1.2.1. a "global status" property of the Adium application object which can be used to manipulate the status of all accounts.

comment:11 Changed 13 years ago by Evan Schoenberg

Milestone: Adium X 1.2.1Adium X 1.2.2

comment:12 in reply to:  10 Changed 13 years ago by Hunter Freyer

Replying to evands:

I've also added for 1.2.1. a "global status" property of the Adium application object which can be used to manipulate the status of all accounts.

I've tried using this in Applescript with Adium 1.2.1b1, and I can't get it to work. I have a hunch that "global" is a reserved word, and that it makes Applescript angry when trying to set the property.

If it does work, do you have an example?

comment:13 Changed 13 years ago by Evan Schoenberg

This worksforme in 1.2.1b1:

tell application "Adium" to return message of the global status

comment:14 Changed 13 years ago by Evan Schoenberg

Milestone: Adium X 1.2.2Adium X 1.2.1

comment:15 Changed 13 years ago by Hunter Freyer

That also works for me, so why doesn't this:

tell application "Adium" to set message of the global status to "foobar"

Looking through Adium.sdef, the message property of a status is read only. Is there no way to change the global status in this way?

comment:16 Changed 13 years ago by Lars Eggert

Have the same issue,

tell application "Adium" to set message of the global status to "foobar"

doesn't work. Any fix coming? Every since the set my status message to "Something new" stuff broke, my status scripts have been defunct.

comment:17 Changed 13 years ago by Lars Eggert

Still an issue with 1.2.2b1.

comment:18 Changed 13 years ago by Lars Eggert

Still an issue with 1.2.3.

comment:19 Changed 13 years ago by Eric Richie

Resolution: fixed
Status: closedreopened

comment:20 Changed 13 years ago by Jordan

Component: Adium CoreScripting
Milestone: Adium X 1.2.1Adium X 1.2.5
Severity: normalregression
Summary: AppleScript to change status no longer works in Adium 1.2AppleScript to change status does not work
Version: 1.21.2.3

comment:21 Changed 12 years ago by Jordan

Summary: AppleScript to change status does not workAppleScript to change global status does not work
Version: 1.2.31.2.4

comment:22 Changed 12 years ago by Matt Handley

The code

set message of global status to "test"

does work if the status is a built-in. The problem is that a new temporary status is created with the new message, but the current status does not change. If the status is a user-defined one, the status message does not update. I'm not sure why this is, but it's pretty weird.

My vote is still to remove this syntax, replacing it with the new go <status> [with message <message>] syntax, which removes these odd ambiguities.

tell app "Adium"
go away with message "blah"
go online with message "blah" -- doesn't change the current status type (unless offline)
end

comment:23 Changed 12 years ago by Matt Handley

Owner: changed from nobody to Matt Handley
Status: reopenednew

comment:24 Changed 12 years ago by Matt Handley

Let me be more specific: You can use

tell app "Adium"
  go online with message "something"
end

to change the user's status message to something. If you want to also change the status type, you can use

tell app "Adium"
  go available with message "something" -- or away or invisible
end

comment:25 Changed 12 years ago by Evan Schoenberg

Any attempt I make to change the message of any status (built-in, saved, or custom) only produces an error Adium got an error: Can’t set message of status to "test". with the following debug output:

2008-04-24 06:58:07.820 Adium[32521:10b] Command: Intrinsics.set
	Direct Parameter: <NSPropertySpecifier: scriptingMessage>
	Receivers: <NSPropertySpecifier: globalStatus>
	Arguments:     {
        Value = <NSAppleEventDescriptor: 'utxt'("test")>;
    }
	Key Specifier: <NSPropertySpecifier: scriptingMessage>
2008-04-24 06:58:07.821 Adium[32521:10b] Result: (null)
2008-04-24 06:58:07.828 Adium[32521:10b] Error: -10003 "(null)"

comment:26 Changed 12 years ago by Evan Schoenberg

The setScriptingMessage: method in AIStatus isn't even called.

comment:27 Changed 12 years ago by Evan Schoenberg

Milestone: Adium X 1.2.5Adium X 1.2.x

comment:28 Changed 12 years ago by Jordan

Milestone: Adium X 1.2.xAdium X 1.3.x

comment:29 Changed 12 years ago by Carlos Morales

comment:30 Changed 12 years ago by Matt Handley

Resolution: fixed
Status: newclosed

(In [23991]) In what may be the most amount of time spent on debugging a problem with an obvious solution, I have changed the various status properties to be rw, rather than just r. 10.4 completely ignores this flag, but 10.5 respects it. Fixes #8809. Fixes #10118.

comment:31 Changed 12 years ago by Jordan

Milestone: Adium X 1.3.xAdium X 1.3

comment:32 Changed 8 years ago by Adam

Is there a way to get the Status Message of one of your contacts accounts (not your own account)? I am trying to have this feed into QuickSilver and display in large type.

comment:33 Changed 8 years ago by Adam

After searching for weeks I just figured it out!

tell application "Adium" to get status message of contact "userx@…"

It might be helpful to run one of the following first.

tell application "Adium" to get every contact of account "myaccount@…"

or use this for every account

tell application "Adium" to get every contact

comment:34 Changed 8 years ago by Adam

tell application "Adium" to get status message of contact "coolbeans@…"

set statusMessage to result

--say statusMessage

tell application "Quicksilver" to show large type statusMessage

Note: See TracTickets for help on using tickets.