Adium

Ticket #8809 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

AppleScript to change global status does not work

Reported by: chockenberry Owned by: applmak
Milestone: Adium 1.3 Component: AppleScript
Version: 1.2.4 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

  Changed 3 years ago by djmori

  • version set to 1.2
  • pending changed from 0 to 1

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

  Changed 3 years ago by chockenberry

  • pending changed from 1 to 0

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

  Changed 3 years ago by chockenberry

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.

  Changed 3 years ago by chockenberry

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.

  Changed 3 years ago by jas8522

  • status changed from new to closed
  • resolution set to invalid

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

  Changed 3 years ago by applmak

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.

  Changed 3 years ago by chockenberry

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.

  Changed 3 years ago by applmak

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.

  Changed 3 years ago by evands

  • status changed from closed to reopened
  • resolution invalid deleted

follow-up: ↓ 12   Changed 3 years ago by evands

  • status changed from reopened to closed
  • resolution set to fixed
  • milestone set to Adium X 1.2.1

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.

  Changed 3 years ago by evands

  • milestone changed from Adium X 1.2.1 to Adium X 1.2.2

in reply to: ↑ 10   Changed 3 years ago by hjfreyer

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?

  Changed 3 years ago by evands

This worksforme in 1.2.1b1:

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

  Changed 3 years ago by evands

  • milestone changed from Adium X 1.2.2 to Adium X 1.2.1

  Changed 3 years ago by hjfreyer

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?

  Changed 3 years ago by larse

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.

  Changed 2 years ago by larse

Still an issue with 1.2.2b1.

  Changed 2 years ago by larse

Still an issue with 1.2.3.

  Changed 2 years ago by edr1084

  • status changed from closed to reopened
  • resolution fixed deleted

  Changed 2 years ago by jas8522

  • summary changed from AppleScript to change status no longer works in Adium 1.2 to AppleScript to change status does not work
  • component changed from Adium Core to Scripting
  • severity changed from normal to regression
  • version changed from 1.2 to 1.2.3
  • milestone changed from Adium X 1.2.1 to Adium X 1.2.5

  Changed 2 years ago by jas8522

  • version changed from 1.2.3 to 1.2.4
  • summary changed from AppleScript to change status does not work to AppleScript to change global status does not work

  Changed 2 years ago by applmak

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

  Changed 2 years ago by applmak

  • owner changed from nobody to applmak
  • status changed from reopened to new

  Changed 2 years ago by applmak

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

  Changed 2 years ago by evands

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)"

  Changed 2 years ago by evands

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

  Changed 2 years ago by evands

  • milestone changed from Adium X 1.2.5 to Adium X 1.2.x

  Changed 2 years ago by jas8522

  • milestone changed from Adium X 1.2.x to Adium X 1.3.x

  Changed 2 years ago by djmori

  Changed 2 years ago by applmak

  • status changed from new to closed
  • resolution set to fixed

(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.

  Changed 2 years ago by jas8522

  • milestone changed from Adium X 1.3.x to Adium X 1.3
Note: See TracTickets for help on using tickets.