Opened 13 years ago

Last modified 9 years ago

#15 new Defect

AS: 'process outgoing chat message' is called by 'send' which can cause dead loops

Reported by: Brennan Owned by: timothy
Component: Colloquy (Mac) Version: 2.1 (Mac)
Severity: Normal Keywords: AS process outgoing chat message send
Cc: brennan@…

Description

I am fond of making text input 'filter' scripts, for example the following script is intended to insert a space between each of the characters of the text input :

using terms from application "Colloquy"
	
	on process outgoing chat message msg in chatView
		
		set msgTxt to (body of msg as string)
		set AppleScript's text item delimiters to " "
		set msgchars to (characters of msgTxt) as string
		set AppleScript's text item delimiters to ""
		send chatView message msgchars
		
		return false
		
	end process outgoing chat message
	
end using terms from

The result of this is that typing 'hello' would appear as 'h e l l o'. (More advanced/specialised filters can easily be imagined).

The problem is that when I 'send' my filtered message from 'process outgoing chat message', 'process outgoing chat message' gets called again, leading to a dead loop.

There are a couple of possible solutions to this problem, but I would suggest an optional extra parameter for 'send' which would ensure that 'process outgoing chat message' does not get called. The exact implementation is not so important however. Whatever works out.

Change History (6)

comment:1 Changed 13 years ago by anonymous

"There are a couple of possible solutions to this problem, but I would suggest an optional extra parameter for 'send' which would ensure that 'process outgoing chat message' does not get called. "

I would recommend the opposite - by default, use the Send that does NOT call the plugin handlers. If this error exists in a script, it is because the author is careless; the odds are not good that the author will think to include the optional parameter.

I'd suggest "send chatView message msgchars with plugins" or something to that effect. If this parameter does not exist, it defaults to false and no plugin handlers will be called.

In addition, more often than not, the script author does not want or need the text to be post-processed.

comment:2 Changed 13 years ago by stacey

am sorry that i said what i said i'm sorry lov u lots lov stacey

comment:3 Changed 13 years ago by brennan@…

"send chatView message msgchars with plugins" is good :)

comment:4 Changed 13 years ago by anonymous

  • Version changed from 2.0 (2C11) to 2.0 (2D16)

comment:5 Changed 10 years ago by Rinoa

  • Version changed from 2.0 (Mac) to 2.1 (Mac)

Valid as of latest build.

comment:6 Changed 9 years ago by akempgen

  • Component changed from Colloquy (Mac) to AppleScript Support
Note: See TracTickets for help on using tickets.