Opened 12 years ago

Last modified 11 years ago

#915 assigned Defect

Many AppleScript errors while doing simple scripting tasks

Reported by: Brennan Owned by: timothy
Component: Colloquy (Mac) Version: 2.2 (Mac)
Severity: Critical Keywords:
Cc:

Description

After routine testing, I've discovered that many ofl the Applescript callback handlers mentioned in the scripting dictionary do not get called.

The only ones I can get working are:

load

unload

kicked from room

idle

build contextual menu for item

handle clicked contextual menu item

I haven't tested the ctcp handlers yet ('process subcode request' and 'process subcode reply'), but ALL the others fail silently.

This is a fairly serious bug for anyone wanting to script Colloquy with AppleScript?.

Here's a test suite:

property loadedScriptName : ""

using terms from application "Colloquy"
 
 (*****************Load/Unload Handlers*****************)
 on load from scriptPath
  set scriptAlias to (POSIX file scriptPath) as alias
  set loadedScriptName to (name of (info for scriptAlias))
  
  set msg to (loadedScriptName & " Loaded") as string
  set evt to (loadedScriptName & "loaded") as string
  tell active panel of front window
   add event message msg with name evt
  end tell
 end load
 
 on unload
  set msg to (loadedScriptName & " Unloaded") as string
  set evt to (loadedScriptName & "unloaded") as string
  tell active panel of front window
   add event message msg with name evt
  end tell
  set loadedScriptName to ""
 end unload
 
 (*****************Contextual Menu Handlers*****************)
 
 on build contextual menu for item whichItems in whichPanel
  return {"test one", "test two", "test three"}
 end build contextual menu for item
 
 
 on handle clicked contextual menu item whichMenuItem for whichItems within whichMenuList
  if (whichMenuItem as string) begins with "test" then
   tell active panel of front window
    add event message "contextual menu test" with name "test123..."
   end tell
  end if
 end handle clicked contextual menu item
 
 on handle clicked link whichURL in whichPanel
  if whichURL is "http://www.testing123.com" then
   tell active panel of front window
    add event message "handle clicked link" with name "test123..."
   end tell
   return true
  end if
  return false
 end handle clicked link
 
 
 (*****************Message Handlers*****************)
 
 on process user command whichCommand with whichArguments for whichPanel
  if whichCommand is "!test123" then
   display dialog "ok" default answer whichArguments
   return true
  end if
  return false
 end process user command
 
 on process incoming chat message whatMessage from whichUser in whichPanel
  if whatMessage is "test123" then
   tell active panel of front window
    add event message "processing incoming chat message" with name "test123..."
   end tell
  end if
 end process incoming chat message
 
 on process outgoing chat message whatMessage in whichPanel
  if whatMessage is "test123" then
   tell active panel of front window
    add event message "processing outgoing chat message" with name "test123..."
   end tell
  end if
 end process outgoing chat message
 
 (*****************CTCP Handlers*****************)
 on process subcode request whichRequest with whichArguments from whichUser on whichConnection
  return false
 end process subcode request
 
 on process subcode reply with whichArguments from whichUser on whichConnection
  return false
 end process subcode reply
 
 
 (***************** Handlers for Connecting and Disconnecting *****************)
 
 on connected whichConnection
  display dialog "connected to " & (whichConnection's id)
 end connected
 
 on disconnecting whichConnection
  display dialog "disconnecting from " & (whichConnection's id)
 end disconnecting
 
 (***************** Handlers for Joining, Leaving and Kicking *****************)
 
 on join chat room whichPanel
  tell active panel of front window
   add event message ("joining" & whichPanel's id) with name "test123..."
  end tell
 end join chat room
 
 on parting chat room whichPanel
  tell active panel of front window
   add event message ("parting" & whichPanel's id) with name "test123..."
  end tell
 end parting chat room
 
 on kicked from room whichPanel by whichUser for whatReason
  tell active panel of front window
   add event message ("you were kicked from" & whichPanel's id) with name "test123..."
  end tell
 end kicked from room
 
 on member joined whichMember in whichPanel
  tell active panel of front window
   add event message (whichMember's id & "joined" & whichPanel's id) with name "test123..."
  end tell
 end member joined
 
 on member parted whichMember from whichPanel for whatReason
  tell active panel of front window
   add event message (whichMember's id & "parted from" & whichPanel's id) with name "test123..."
  end tell
 end member parted
 
 on member kicked whichMember from whichPanel by whichOp for whatReason
  tell active panel of front window
   add event message ((whichMember's id) & "was kicked from" & (whichPanel's id) & " by " & (whichOp's id)) with name "test123..."
  end tell
 end member kicked
 
 (***************** Other Handlers *****************)
 
 on topic changed in whichPanel by whichUser to newTopic
  tell active panel of front window
   add event message (whichUser's id & "changed the topic of " & (whichPanel's id)) with name "test123..."
  end tell
 end topic changed
 
 on perform notification whichNotification with whichNotificationInfo and whichPreferences
  --
 end perform notification
 
 on idle
  tell active panel of front window
   --add event message ("idle") with name "test123..."
  end tell
  return 10.0
 end idle
 
end using terms from

[applescript://com.apple.scripteditor?action=new&script=property%20loadedScriptName%20%3A%20%22%22%0D%0Dusing%20terms%20from%20application%20%22Colloquy%22%0D%20%0D%20%28%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2ALoad%2FUnload%20Handlers%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%29%0D%20on%20load%20from%20scriptPath%0D%20%20set%20scriptAlias%20to%20%28POSIX%20file%20scriptPath%29%20as%20alias%0D%20%20set%20loadedScriptName%20to%20%28name%20of%20%28info%20for%20scriptAlias%29%29%0D%20%20%0D%20%20set%20msg%20to%20%28loadedScriptName%20%26%20%22%20Loaded%22%29%20as%20string%0D%20%20set%20evt%20to%20%28loadedScriptName%20%26%20%22loaded%22%29%20as%20string%0D%20%20tell%20active%20panel%20of%20front%20window%0D%20%20%20add%20event%20message%20msg%20with%20name%20evt%0D%20%20end%20tell%0D%20end%20load%0D%20%0D%20on%20unload%0D%20%20set%20msg%20to%20%28loadedScriptName%20%26%20%22%20Unloaded%22%29%20as%20string%0D%20%20set%20evt%20to%20%28loadedScriptName%20%26%20%22unloaded%22%29%20as%20string%0D%20%20tell%20active%20panel%20of%20front%20window%0D%20%20%20add%20event%20message%20msg%20with%20name%20evt%0D%20%20end%20tell%0D%20%20set%20loadedScriptName%20to%20%22%22%0D%20end%20unload%0D%20%0D%20%28%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2AContextual%20Menu%20Handlers%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%29%0D%20%0D%20on%20build%20contextual%20menu%20for%20item%20whichItems%20in%20whichPanel%0D%20%20return%20%7B%22test%20one%22%2C%20%22test%20two%22%2C%20%22test%20three%22%7D%0D%20end%20build%20contextual%20menu%20for%20item%0D%20%0D%20%0D%20on%20handle%20clicked%20contextual%20menu%20item%20whichMenuItem%20for%20whichItems%20within%20whichMenuList%0D%20%20if%20%28whichMenuItem%20as%20string%29%20begins%20with%20%22test%22%20then%0D%20%20%20tell%20active%20panel%20of%20front%20window%0D%20%20%20%20add%20event%20message%20%22contextual%20menu%20test%22%20with%20name%20%22test123%2E%2E%2E%22%0D%20%20%20end%20tell%0D%20%20end%20if%0D%20end%20handle%20clicked%20contextual%20menu%20item%0D%20%0D%20on%20handle%20clicked%20link%20whichURL%20in%20whichPanel%0D%20%20if%20whichURL%20is%20%22http%3A%2F%2Fwww%2Etesting123%2Ecom%22%20then%0D%20%20%20tell%20active%20panel%20of%20front%20window%0D%20%20%20%20add%20event%20message%20%22handle%20clicked%20link%22%20with%20name%20%22test123%2E%2E%2E%22%0D%20%20%20end%20tell%0D%20%20%20return%20true%0D%20%20end%20if%0D%20%20return%20false%0D%20end%20handle%20clicked%20link%0D%20%0D%20%0D%20%28%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2AMessage%20Handlers%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%29%0D%20%0D%20on%20process%20user%20command%20whichCommand%20with%20whichArguments%20for%20whichPanel%0D%20%20if%20whichCommand%20is%20%22%21test123%22%20then%0D%20%20%20display%20dialog%20%22ok%22%20default%20answer%20whichArguments%0D%20%20%20return%20true%0D%20%20end%20if%0D%20%20return%20false%0D%20end%20process%20user%20command%0D%20%0D%20on%20process%20incoming%20chat%20message%20whatMessage%20from%20whichUser%20in%20whichPanel%0D%20%20if%20whatMessage%20is%20%22test123%22%20then%0D%20%20%20tell%20active%20panel%20of%20front%20window%0D%20%20%20%20add%20event%20message%20%22processing%20incoming%20chat%20message%22%20with%20name%20%22test123%2E%2E%2E%22%0D%20%20%20end%20tell%0D%20%20end%20if%0D%20end%20process%20incoming%20chat%20message%0D%20%0D%20on%20process%20outgoing%20chat%20message%20whatMessage%20in%20whichPanel%0D%20%20if%20whatMessage%20is%20%22test123%22%20then%0D%20%20%20tell%20active%20panel%20of%20front%20window%0D%20%20%20%20add%20event%20message%20%22processing%20outgoing%20chat%20message%22%20with%20name%20%22test123%2E%2E%2E%22%0D%20%20%20end%20tell%0D%20%20end%20if%0D%20end%20process%20outgoing%20chat%20message%0D%20%0D%20%28%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2ACTCP%20Handlers%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%29%0D%20on%20process%20subcode%20request%20whichRequest%20with%20whichArguments%20from%20whichUser%20on%20whichConnection%0D%20%20return%20false%0D%20end%20process%20subcode%20request%0D%20%0D%20on%20process%20subcode%20reply%20with%20whichArguments%20from%20whichUser%20on%20whichConnection%0D%20%20return%20false%0D%20end%20process%20subcode%20reply%0D%20%0D%20%0D%20%28%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%20Handlers%20for%20Connecting%20and%20Disconnecting%20%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%29%0D%20%0D%20on%20connected%20whichConnection%0D%20%20display%20dialog%20%22connected%20to%20%22%20%26%20%28whichConnection%27s%20id%29%0D%20end%20connected%0D%20%0D%20on%20disconnecting%20whichConnection%0D%20%20display%20dialog%20%22disconnecting%20from%20%22%20%26%20%28whichConnection%27s%20id%29%0D%20end%20disconnecting%0D%20%0D%20%28%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%20Handlers%20for%20Joining%2C%20Leaving%20and%20Kicking%20%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%29%0D%20%0D%20on%20join%20chat%20room%20whichPanel%0D%20%20tell%20active%20panel%20of%20front%20window%0D%20%20%20add%20event%20message%20%28%22joining%22%20%26%20whichPanel%27s%20id%29%20with%20name%20%22test123%2E%2E%2E%22%0D%20%20end%20tell%0D%20end%20join%20chat%20room%0D%20%0D%20on%20parting%20chat%20room%20whichPanel%0D%20%20tell%20active%20panel%20of%20front%20window%0D%20%20%20add%20event%20message%20%28%22parting%22%20%26%20whichPanel%27s%20id%29%20with%20name%20%22test123%2E%2E%2E%22%0D%20%20end%20tell%0D%20end%20parting%20chat%20room%0D%20%0D%20on%20kicked%20from%20room%20whichPanel%20by%20whichUser%20for%20whatReason%0D%20%20tell%20active%20panel%20of%20front%20window%0D%20%20%20add%20event%20message%20%28%22you%20were%20kicked%20from%22%20%26%20whichPanel%27s%20id%29%20with%20name%20%22test123%2E%2E%2E%22%0D%20%20end%20tell%0D%20end%20kicked%20from%20room%0D%20%0D%20on%20member%20joined%20whichMember%20in%20whichPanel%0D%20%20tell%20active%20panel%20of%20front%20window%0D%20%20%20add%20event%20message%20%28whichMember%27s%20id%20%26%20%22joined%22%20%26%20whichPanel%27s%20id%29%20with%20name%20%22test123%2E%2E%2E%22%0D%20%20end%20tell%0D%20end%20member%20joined%0D%20%0D%20on%20member%20parted%20whichMember%20from%20whichPanel%20for%20whatReason%0D%20%20tell%20active%20panel%20of%20front%20window%0D%20%20%20add%20event%20message%20%28whichMember%27s%20id%20%26%20%22parted%20from%22%20%26%20whichPanel%27s%20id%29%20with%20name%20%22test123%2E%2E%2E%22%0D%20%20end%20tell%0D%20end%20member%20parted%0D%20%0D%20on%20member%20kicked%20whichMember%20from%20whichPanel%20by%20whichOp%20for%20whatReason%0D%20%20tell%20active%20panel%20of%20front%20window%0D%20%20%20add%20event%20message%20%28%28whichMember%27s%20id%29%20%26%20%22was%20kicked%20from%22%20%26%20%28whichPanel%27s%20id%29%20%26%20%22%20by%20%22%20%26%20%28whichOp%27s%20id%29%29%20with%20name%20%22test123%2E%2E%2E%22%0D%20%20end%20tell%0D%20end%20member%20kicked%0D%20%0D%20%28%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%20Other%20Handlers%20%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%29%0D%20%0D%20on%20topic%20changed%20in%20whichPanel%20by%20whichUser%20to%20newTopic%0D%20%20tell%20active%20panel%20of%20front%20window%0D%20%20%20add%20event%20message%20%28whichUser%27s%20id%20%26%20%22changed%20the%20topic%20of%20%22%20%26%20%28whichPanel%27s%20id%29%29%20with%20name%20%22test123%2E%2E%2E%22%0D%20%20end%20tell%0D%20end%20topic%20changed%0D%20%0D%20on%20perform%20notification%20whichNotification%20with%20whichNotificationInfo%20and%20whichPreferences%0D%20%20%2D%2D%0D%20end%20perform%20notification%0D%20%0D%20on%20idle%0D%20%20tell%20active%20panel%20of%20front%20window%0D%20%20%20%2D%2Dadd%20event%20message%20%28%22idle%22%29%20with%20name%20%22test123%2E%2E%2E%22%0D%20%20end%20tell%0D%20%20return%2010%2E0%0D%20end%20idle%0D%20%0Dend%20using%20terms%20from" Click here to open the script in script editor]

Change History (8)

comment:1 Changed 12 years ago by Brennan

Just a little update: "on connected" is firing ok.

comment:2 Changed 12 years ago by timothy

Clicked URL only works if you exactly match the URL. OS X will add a / to the URL if there was not one earlier. So this code works:

on handle clicked link whichURL in whichPanel
		if whichURL is "http://www.testing123.com/" then
...

comment:3 Changed 12 years ago by timothy

  • Status changed from new to assigned
  • Summary changed from Most Applescript callback handlers do not get called to Many AppleScript errors while doing simple scripting tasks

comment:4 Changed 12 years ago by timothy

All of these handlers do work, however you are getting errors in most of them that prevent the add event or display dialog. Some of these errors are problems in Colloquy and I will look into it. You should always use the try/on error/end try when testing, or the JVEnableAppleScriptDebugging hidden preference.

comment:5 Changed 12 years ago by timothy

Actually most of the problem seems to be the "whichMember's id" statments. These need to be "whichMember's id as string" to work. I am not sure yet if this is a Colloquy bug, but I doubt it.

comment:6 Changed 12 years ago by Brennan

OK, here is the new test suite with 'as string' added. It fixes some of these problems but not all.

[applescript://com.apple.scripteditor?action=new&script=property%20loadedScriptName%20%3A%20%22%22%0D%0Dusing%20terms%20from%20application%20%22Colloquy%22%0D%09%0D%09%28%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2ALoad%2FUnload%20Handlers%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%29%0D%09on%20load%20from%20scriptPath%0D%09%09set%20scriptAlias%20to%20%28POSIX%20file%20scriptPath%29%20as%20alias%0D%09%09set%20loadedScriptName%20to%20%28name%20of%20%28info%20for%20scriptAlias%29%29%0D%09%09%0D%09%09set%20msg%20to%20%28loadedScriptName%20%26%20%22%20Loaded%22%29%20as%20string%0D%09%09set%20evt%20to%20%28loadedScriptName%20%26%20%22loaded%22%29%20as%20string%0D%09%09tell%20active%20panel%20of%20front%20window%0D%09%09%09add%20event%20message%20msg%20with%20name%20evt%0D%09%09end%20tell%0D%09end%20load%0D%09%0D%09on%20unload%0D%09%09set%20msg%20to%20%28loadedScriptName%20%26%20%22%20Unloaded%22%29%20as%20string%0D%09%09set%20evt%20to%20%28loadedScriptName%20%26%20%22unloaded%22%29%20as%20string%0D%09%09tell%20active%20panel%20of%20front%20window%0D%09%09%09add%20event%20message%20msg%20with%20name%20evt%0D%09%09end%20tell%0D%09%09set%20loadedScriptName%20to%20%22%22%0D%09end%20unload%0D%09%0D%09%28%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2AContextual%20Menu%20Handlers%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%29%0D%09%0D%09on%20build%20contextual%20menu%20for%20item%20whichItems%20in%20whichPanel%0D%09%09return%20%7B%22test%20one%22%2C%20%22test%20two%22%2C%20%22test%20three%22%7D%0D%09end%20build%20contextual%20menu%20for%20item%0D%09%0D%09%0D%09on%20handle%20clicked%20contextual%20menu%20item%20whichMenuItem%20for%20whichItems%20within%20whichMenuList%0D%09%09if%20%28whichMenuItem%20as%20string%29%20begins%20with%20%22test%22%20then%0D%09%09%09tell%20active%20panel%20of%20front%20window%0D%09%09%09%09add%20event%20message%20%22contextual%20menu%20test%22%20with%20name%20%22test123%2E%2E%2E%22%0D%09%09%09end%20tell%0D%09%09end%20if%0D%09end%20handle%20clicked%20contextual%20menu%20item%0D%09%0D%09on%20handle%20clicked%20link%20whichURL%20in%20whichPanel%0D%09%09if%20whichURL%20is%20%22http%3A%2F%2Fwww%2Etesting123%2Ecom%22%20then%0D%09%09%09tell%20active%20panel%20of%20front%20window%0D%09%09%09%09add%20event%20message%20%22handle%20clicked%20link%22%20with%20name%20%22test123%2E%2E%2E%22%0D%09%09%09end%20tell%0D%09%09%09return%20true%0D%09%09end%20if%0D%09%09return%20false%0D%09end%20handle%20clicked%20link%0D%09%0D%09%0D%09%28%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2AMessage%20Handlers%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%29%0D%09%0D%09on%20process%20user%20command%20whichCommand%20with%20whichArguments%20for%20whichPanel%0D%09%09if%20whichCommand%20is%20%22%21test123%22%20then%0D%09%09%09display%20dialog%20%22ok%22%20default%20answer%20whichArguments%0D%09%09%09return%20true%0D%09%09end%20if%0D%09%09return%20false%0D%09end%20process%20user%20command%0D%09%0D%09on%20process%20incoming%20chat%20message%20whatMessage%20from%20whichUser%20in%20whichPanel%0D%09%09if%20whatMessage%20is%20%22test123%22%20then%0D%09%09%09tell%20active%20panel%20of%20front%20window%0D%09%09%09%09add%20event%20message%20%22processing%20incoming%20chat%20message%22%20with%20name%20%22test123%2E%2E%2E%22%0D%09%09%09end%20tell%0D%09%09end%20if%0D%09end%20process%20incoming%20chat%20message%0D%09%0D%09on%20process%20outgoing%20chat%20message%20whatMessage%20in%20whichPanel%0D%09%09if%20whatMessage%20is%20%22test123%22%20then%0D%09%09%09tell%20active%20panel%20of%20front%20window%0D%09%09%09%09add%20event%20message%20%22processing%20outgoing%20chat%20message%22%20with%20name%20%22test123%2E%2E%2E%22%0D%09%09%09end%20tell%0D%09%09end%20if%0D%09end%20process%20outgoing%20chat%20message%0D%09%0D%09%28%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2ACTCP%20Handlers%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%29%0D%09on%20process%20subcode%20request%20whichRequest%20with%20whichArguments%20from%20whichUser%20on%20whichConnection%0D%09%09return%20false%0D%09end%20process%20subcode%20request%0D%09%0D%09on%20process%20subcode%20reply%20with%20whichArguments%20from%20whichUser%20on%20whichConnection%0D%09%09return%20false%0D%09end%20process%20subcode%20reply%0D%09%0D%09%0D%09%28%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%20Handlers%20for%20Connecting%20and%20Disconnecting%20%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%29%0D%09%0D%09on%20connected%20whichConnection%0D%09%09display%20dialog%20%22connected%20to%20%22%20%26%20%28%28whichConnection%27s%20id%29%20as%20string%29%0D%09end%20connected%0D%09%0D%09on%20disconnecting%20whichConnection%0D%09%09display%20dialog%20%22disconnecting%20from%20%22%20%26%20%28%28whichConnection%27s%20id%29%20as%20string%29%0D%09end%20disconnecting%0D%09%0D%09%28%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%20Handlers%20for%20Joining%2C%20Leaving%20and%20Kicking%20%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%29%0D%09%0D%09on%20join%20chat%20room%20whichPanel%0D%09%09tell%20active%20panel%20of%20front%20window%0D%09%09%09add%20event%20message%20%28%22joining%22%20%26%20%28whichPanel%27s%20id%20as%20string%29%29%20with%20name%20%22test123%2E%2E%2E%22%0D%09%09end%20tell%0D%09end%20join%20chat%20room%0D%09%0D%09on%20parting%20chat%20room%20whichPanel%0D%09%09tell%20active%20panel%20of%20front%20window%0D%09%09%09add%20event%20message%20%28%22parting%22%20%26%20%28whichPanel%27s%20id%20as%20string%29%29%20with%20name%20%22test123%2E%2E%2E%22%0D%09%09end%20tell%0D%09end%20parting%20chat%20room%0D%09%0D%09on%20kicked%20from%20room%20whichPanel%20by%20whichUser%20for%20whatReason%0D%09%09tell%20active%20panel%20of%20front%20window%0D%09%09%09add%20event%20message%20%28%22you%20were%20kicked%20from%22%20%26%20%28whichPanel%27s%20id%20as%20string%29%29%20with%20name%20%22test123%2E%2E%2E%22%0D%09%09end%20tell%0D%09end%20kicked%20from%20room%0D%09%0D%09on%20member%20joined%20whichMember%20in%20whichPanel%0D%09%09tell%20active%20panel%20of%20front%20window%0D%09%09%09add%20event%20message%20%28%28whichMember%27s%20id%20as%20string%29%20%26%20%22joined%22%20%26%20%28whichPanel%27s%20id%20as%20string%29%29%20with%20name%20%22test123%2E%2E%2E%22%0D%09%09end%20tell%0D%09end%20member%20joined%0D%09%0D%09on%20member%20parted%20whichMember%20from%20whichPanel%20for%20whatReason%0D%09%09tell%20active%20panel%20of%20front%20window%0D%09%09%09add%20event%20message%20%28%28whichMember%27s%20id%20as%20string%29%20%26%20%22parted%20from%22%20%26%20%28whichPanel%27s%20id%20as%20string%29%29%20with%20name%20%22test123%2E%2E%2E%22%0D%09%09end%20tell%0D%09end%20member%20parted%0D%09%0D%09on%20member%20kicked%20whichMember%20from%20whichPanel%20by%20whichOp%20for%20whatReason%0D%09%09tell%20active%20panel%20of%20front%20window%0D%09%09%09add%20event%20message%20%28%28%28whichMember%27s%20id%20as%20string%29%29%20%26%20%22was%20kicked%20from%22%20%26%20%28%28whichPanel%27s%20id%20as%20string%29%29%20%26%20%22%20by%20%22%20%26%20%28whichOp%27s%20id%29%29%20with%20name%20%22test123%2E%2E%2E%22%0D%09%09end%20tell%0D%09end%20member%20kicked%0D%09%0D%09%28%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%20Other%20Handlers%20%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%29%0D%09%0D%09on%20topic%20changed%20in%20whichPanel%20by%20whichUser%20to%20newTopic%0D%09%09tell%20active%20panel%20of%20front%20window%0D%09%09%09add%20event%20message%20%28whichUser%27s%20id%20%26%20%22changed%20the%20topic%20of%20%22%20%26%20%28%28whichPanel%27s%20id%20as%20string%29%29%29%20with%20name%20%22test123%2E%2E%2E%22%0D%09%09end%20tell%0D%09end%20topic%20changed%0D%09%0D%09on%20perform%20notification%20whichNotification%20with%20whichNotificationInfo%20and%20whichPreferences%0D%09%09%2D%2D%0D%09end%20perform%20notification%0D%09%0D%09on%20idle%0D%09%09tell%20active%20panel%20of%20front%20window%0D%09%09%09%2D%2Dadd%20event%20message%20%28%22idle%22%29%20with%20name%20%22test123%2E%2E%2E%22%0D%09%09end%20tell%0D%09%09return%2010%2E0%0D%09end%20idle%0D%09%0Dend%20using%20terms%20from click here to test the NEW script]

comment:7 Changed 11 years ago by frosty

I am experiencing this phenomenon again... Started AppleScripting Colloquy again after a couple of months or years I hadn't used it... I can't seem to process incoming text. When I try and on error it, it reports about 40 errors. Enabling the hidden preference lets me start Colloquy with tons of error messages about errors in my scripts while processing incoming text, but it then does not or only partially connect to channels.
Curious thing is, that even with having the hidden prefrence deactivated, some of my old scripts don't run anymore. I cross checked with the new Colloquy AppleScript? Library thing and everything looks fine.

As this ticket is rather ancient, is there likely to be a guide on how to correctly use process incoming text and such or should I rather start my scripts over in JavaScript??

comment:8 Changed 11 years ago by Brennan

Hey frosty, this seems to be working for me:

using terms from application "Colloquy"
	
	on process incoming chat message whatMessage from whichUser in whichPanel
		set msgTxt to ((HTML of whatMessage) as string)
		display dialog msgTxt giving up after 1
		
		repeat while true
			try
				--my writeLog("as string: " & (whatMessage) as string) -- appears to be broken
				
				my writeLog("body: " & (body of whatMessage) as string) -- appears to be broken
				
				--my writeLog((id of whatMessage) as string) -- appears to be broken
				--my writeLog((sender of whatMessage) as string) -- is class 'item' and can't be coerced to string, use the 'whichUser' parameter instead
				
				my writeLog("sender: " & (name of whichUser) as string)
				
				my writeLog("timestamp: " & (timestamp of whatMessage) as string)
				my writeLog("highlighted: " & (highlighted of whatMessage) as string)
				my writeLog("action tense: " & (action tense of whatMessage) as string)
				my writeLog("HTML: " & (HTML of whatMessage) as string)
				my writeLog("ignore status: " & (ignore status of whatMessage) as string) -- is an enumeration
				my writeLog(" ")
				exit repeat
				
			on error msg number n
				my writeLog((msg) as string)
				exit repeat
			end try
			
		end repeat
		(*		*)
		if msgTxt is "test123" then
			tell active panel of front window
				add event message "processing incoming chat message" with name "test123..."
			end tell
		end if
	end process incoming chat message
	
end using terms from

on writeLog(str)
	tell application "TextEdit"
		if not (document 1 exists) then
			make new document at end
		end if
		tell document 1
			make new paragraph at end with data (str & return)
		end tell
	end tell
	
end writeLog

Not sure why the 'big' script fails. This smaller snippet seems to do the right thing. (Note that it poos in your frontmost TextEdit? document. Thanks to the writeLog handler I put together for debugging purposes. Just a warning).

Don't hesitate to get in touch if you want to discuss Applescript on colloquy (or any other chat client for that matter)

Note: See TracTickets for help on using tickets.