Changes between Version 1 and Version 2 of Documentation/AppleScripting


Ignore:
Timestamp:
Feb 24, 2006 1:36:30 PM (14 years ago)
Author:
akempgen
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Documentation/AppleScripting

    v1 v2  
    44= !AppleScripting = 
    55 
    6 ---- 
     6[[PageOutline(2-3,, inline)]] 
     7 
    78See Also AppleScriptPlugins 
    8 ---- 
    9 = Compatibility with scripts written for Colloquy 2C11 and before = 
    10 In order to provide enhanced scripting support, Colloquy’s AppleScript terminology has been completely re-written. Due to the extensive nature of the scripting enhancements, scripts written to work with previous versions of Colloquy are not guaranteed to be compatible with the 2D9 release. All scripts should be validated against the AppleScript dictionary in Colloquy 2D9. 
    11 ---- 
    12 = Scripting Basics = 
     9 
     10== Compatibility with scripts written for Colloquy 2C11 and before == 
     11In order to provide enhanced scripting support, Colloquy’s !AppleScript terminology has been completely re-written. Due to the extensive nature of the scripting enhancements, scripts written to work with previous versions of Colloquy are not guaranteed to be compatible with the 2D9 release. All scripts should be validated against the !AppleScript dictionary in Colloquy 2D9. 
     12 
     13== Scripting Basics == 
    1314The very first thing you may need to do is to send some text to a channel or 'PM'. This is achieved most simply in the following way: 
    1415 
     
    5051 
    5152When writing AppleScriptPlugins, the target for a message is often provided as an optional parameter to the handler. For example the callback 'process incoming chat message' sends a parameter 'in', which you can use to (for example) reply to the source of the incoming message. 
    52 ---- 
    53 = Opening The Dictionary = 
    54 All Applescriptable applications provide 'dictionaries' of scripting terminology, describing the various classes of object and their relations to each other, commands and callback handlers. As with any other scriptable application, to see Colloquy's AppleScript dictionary from within Script Editor use "File" -> "Open Dictionary", then select Colloquy from the list. 
     53 
     54== Opening The Dictionary == 
     55All AppleScriptable applications provide 'dictionaries' of scripting terminology, describing the various classes of object and their relations to each other, commands and callback handlers. As with any other scriptable application, to see Colloquy's !AppleScript dictionary from within Script Editor use "File" -> "Open Dictionary", then select Colloquy from the list. 
    5556 
    5657If you wish to streamline this action (it can take a little time to build the list of scriptable applications), make a script to do it for you: 
     
    7879 
    7980This is a general scripting tip which applies to all other scriptable applications. 
    80 ---- 
    81 = Colloquy's AppleScript dictionary has 3 main suites: = 
     81 
     82== Colloquy's !AppleScript dictionary suites == 
     83Colloquy's !AppleScript dictionary has 3 main suites: 
    8284 * The "Chat Core" suite 
    8385 * The "Chat Plug-In" suite 
     
    8991 
    9092The "Colloquy" suite allows for interaction with the application and some more irc functions. 
    91 ---- 
    92 = Caveat = 
     93 
     94== Caveat == 
    9395Using IRC manually it's possible to be impolite, antisocial, aggressive, unpleasant, irritating and generally to accumulate bad karma of all kinds. Typically this will result in you getting kicked or banned from the chatroom in question. Please consider then how much broader are the horizons for causing undesirable effects when you are using a scripting language. In severe cases of network abuse people can (and are) routinely banned from entire servers. 
    9496 
    9597For this reason it is strongly recommended that you open a private channel to carry out testing where possible, so that you don't disrupt the chat experience for others. If you are learning to script colloquy, and seek a tolerant atmosphere for endless iterations of your test messages, you may use the #colloquy-test channel, which even has some human beings looking at it from time to time. In a rare moment you may even find some third party to test your script for you too. 
    96 ---- 
    97 = Posting AppleScripts on the Colloquy Documentation Pages = 
    98 If you wish to add scripts to this or other documentation pages using Apple's handy applescript URL protocol, you can get a script to format your code for Wiki by [applescript://com.apple.scripteditor?action=new&script=%2D%2D%20This%20script%20encodes%20the%20AppleScript%20text%20currently%20on%20the%20clipboard%20in%20a%20format%20suitable%20for%20Colloquy%27s%20Wiki%20pages%0Dtry%0D%09set%20this_text%20to%20%28get%20the%20clipboard%29%20as%20string%0D%09%0D%09set%20encodedText%20to%20my%20encode_text%28this_text%29%0D%09%0D%09set%20theParagraphs%20to%20%28paragraphs%20of%20this_text%29%0D%09set%20AppleScript%27s%20text%20item%20delimiters%20to%20return%20%26%20%22%20%22%0D%09set%20insetText%20to%20theParagraphs%20as%20string%0D%09set%20AppleScript%27s%20text%20item%20delimiters%20to%20%22%22%0D%09%0D%09set%20URL_opening%20to%20%22%5Bapplescript%3A%2F%2Fcom%2Eapple%2Escripteditor%3Faction%3Dnew%26script%3D%22%0D%09%0D%09set%20the%20clipboard%20to%20%28%22%7B%7B%7B%22%20%26%20return%20%26%20insetText%20%26%20return%20%26%20%22%7D%7D%7D%22%20%26%20return%20%26%20URL_opening%20%26%20encodedText%20%26%20%22%20Click%20here%20to%20open%20the%20script%20in%20Script%20Editor%2E%5D%22%29%0D%09display%20dialog%20%22The%20encoded%20script%20has%20been%20placed%20on%20the%20clipboard%2E%22%20buttons%20%7B%22OK%22%7D%20default%20button%201%20with%20icon%201%20giving%20up%20after%202%0Don%20error%20error_message%0D%09display%20dialog%20error_message%20buttons%20%7B%22Cancel%22%7D%20default%20button%201%0Dend%20try%0D%0D%2D%2D%20this%20sub%2Droutine%20is%20used%20to%20encode%20text%20%0Don%20encode_text%28this_text%29%0D%09set%20the%20acceptable_characters%20to%20%22abcdefghijklmnopqrstuvwxyz0123456789_%22%0D%09set%20the%20encoded_text%20to%20%22%22%0D%09set%20the%20character_list%20to%20%7B%7D%0D%09repeat%20with%20this_char%20in%20this_text%0D%09%09set%20this_char%20to%20the%20contents%20of%20this_char%0D%09%09if%20this_char%20is%20in%20the%20acceptable_characters%20then%0D%09%09%09set%20the%20end%20of%20the%20character_list%20to%20this_char%0D%09%09else%0D%09%09%09set%20the%20end%20of%20the%20character_list%20to%20encode_char%28this_char%29%0D%09%09end%20if%0D%09end%20repeat%0D%09return%20%28the%20character_list%29%20as%20string%0Dend%20encode_text%0D%0D%2D%2D%20this%20sub%2Droutine%20is%20used%20to%20encode%20a%20character%20%0Don%20encode_char%28this_char%29%0D%09set%20the%20ASCII_num%20to%20%28the%20ASCII%20number%20this_char%29%0D%09set%20the%20hex_list%20to%20%7B%220%22%2C%20%221%22%2C%20%222%22%2C%20%223%22%2C%20%224%22%2C%20%225%22%2C%20%226%22%2C%20%227%22%2C%20%228%22%2C%20%229%22%2C%20%22A%22%2C%20%22B%22%2C%20%22C%22%2C%20%22D%22%2C%20%22E%22%2C%20%22F%22%7D%0D%09set%20x%20to%20item%20%28%28ASCII_num%20div%2016%29%20%2B%201%29%20of%20the%20hex_list%0D%09set%20y%20to%20item%20%28%28ASCII_num%20mod%2016%29%20%2B%201%29%20of%20the%20hex_list%0D%09return%20%28%22%25%22%20%26%20x%20%26%20y%29%20as%20string%0Dend%20encode_char clicking here.] 
     98 
     99== Posting !AppleScripts on the Colloquy Documentation Pages == 
     100If you wish to add scripts to this or other documentation pages using Apple's handy `applescript://` URL protocol, you can get a script to format your code for Wiki by [applescript://com.apple.scripteditor?action=new&script=%2D%2D%20This%20script%20encodes%20the%20AppleScript%20text%20currently%20on%20the%20clipboard%20in%20a%20format%20suitable%20for%20Colloquy%27s%20Wiki%20pages%0Dtry%0D%09set%20this_text%20to%20%28get%20the%20clipboard%29%20as%20string%0D%09%0D%09set%20encodedText%20to%20my%20encode_text%28this_text%29%0D%09%0D%09set%20theParagraphs%20to%20%28paragraphs%20of%20this_text%29%0D%09set%20AppleScript%27s%20text%20item%20delimiters%20to%20return%20%26%20%22%20%22%0D%09set%20insetText%20to%20theParagraphs%20as%20string%0D%09set%20AppleScript%27s%20text%20item%20delimiters%20to%20%22%22%0D%09%0D%09set%20URL_opening%20to%20%22%5Bapplescript%3A%2F%2Fcom%2Eapple%2Escripteditor%3Faction%3Dnew%26script%3D%22%0D%09%0D%09set%20the%20clipboard%20to%20%28%22%7B%7B%7B%22%20%26%20return%20%26%20insetText%20%26%20return%20%26%20%22%7D%7D%7D%22%20%26%20return%20%26%20URL_opening%20%26%20encodedText%20%26%20%22%20Click%20here%20to%20open%20the%20script%20in%20Script%20Editor%2E%5D%22%29%0D%09display%20dialog%20%22The%20encoded%20script%20has%20been%20placed%20on%20the%20clipboard%2E%22%20buttons%20%7B%22OK%22%7D%20default%20button%201%20with%20icon%201%20giving%20up%20after%202%0Don%20error%20error_message%0D%09display%20dialog%20error_message%20buttons%20%7B%22Cancel%22%7D%20default%20button%201%0Dend%20try%0D%0D%2D%2D%20this%20sub%2Droutine%20is%20used%20to%20encode%20text%20%0Don%20encode_text%28this_text%29%0D%09set%20the%20acceptable_characters%20to%20%22abcdefghijklmnopqrstuvwxyz0123456789_%22%0D%09set%20the%20encoded_text%20to%20%22%22%0D%09set%20the%20character_list%20to%20%7B%7D%0D%09repeat%20with%20this_char%20in%20this_text%0D%09%09set%20this_char%20to%20the%20contents%20of%20this_char%0D%09%09if%20this_char%20is%20in%20the%20acceptable_characters%20then%0D%09%09%09set%20the%20end%20of%20the%20character_list%20to%20this_char%0D%09%09else%0D%09%09%09set%20the%20end%20of%20the%20character_list%20to%20encode_char%28this_char%29%0D%09%09end%20if%0D%09end%20repeat%0D%09return%20%28the%20character_list%29%20as%20string%0Dend%20encode_text%0D%0D%2D%2D%20this%20sub%2Droutine%20is%20used%20to%20encode%20a%20character%20%0Don%20encode_char%28this_char%29%0D%09set%20the%20ASCII_num%20to%20%28the%20ASCII%20number%20this_char%29%0D%09set%20the%20hex_list%20to%20%7B%220%22%2C%20%221%22%2C%20%222%22%2C%20%223%22%2C%20%224%22%2C%20%225%22%2C%20%226%22%2C%20%227%22%2C%20%228%22%2C%20%229%22%2C%20%22A%22%2C%20%22B%22%2C%20%22C%22%2C%20%22D%22%2C%20%22E%22%2C%20%22F%22%7D%0D%09set%20x%20to%20item%20%28%28ASCII_num%20div%2016%29%20%2B%201%29%20of%20the%20hex_list%0D%09set%20y%20to%20item%20%28%28ASCII_num%20mod%2016%29%20%2B%201%29%20of%20the%20hex_list%0D%09return%20%28%22%25%22%20%26%20x%20%26%20y%29%20as%20string%0Dend%20encode_char clicking here.]