action - Make an action or display defined actions
action pattern ?script?
An action consists of a pattern and a tcl script. When mmucl receives text from the mud it checks the pattern of each action to see if that pattern matches the mud output. If it does, then the script associated with the pattern is evaluated. Note that the matching is case insensitive and that the patterns are regexp patterns. Consult your tcl documentation on the regexp command for more information.
Action with two arguments will create an action with pattern as the pattern to be checked for and script as script to be evaluated when the pattern is found. When mud output matches an action's pattern, then the text matching the nth parenthesized expression of the pattern is substituted for "%n" or an empty string if that expression doesn't exist in the script. Up to 9 matches are supported. "%0" is the entire string matched.
Action with no arguments will print out all the currently defined actions. Action with one argument will print out all defined actions matching the pattern given. In this case pattern should be a glob pattern.
action {([a-z]+) grins at ([a-z]+)} {echo "That idiot %1 grinned at %2!!!"}
The string "Mark grins at David" will cause "That idiot Mark grinned at David!!!" to be written to the screen.
action {[a-z]+://[a-z.]+} {exec netscape %0 &}
On finding a url execute netscape and go to it. (I wouldn't recommend doing this. =)
action m*
Print out all the actions that begin with m.
Actions are potentially a big security hole. Don't rule out the possibility that someone could slip some nasty code into text that an action is substituting and then if you call eval on the substituted string, you could be in for a surprise. Someone could execute external programs, modify files, etc. As long as you don't eval a script which contains text substituted in from a mud, there shouldn't be any problems. If you're paranoid, you can execute mmucl in a safe interpreter with the command line option "-safe". Safe interpreters limit somewhat the damage that could be done. For more information read about safe interpreters in your tcl documentation.