Mmucl Procedure

Name

action - Make an action or display defined actions

Synopsis

action pattern ?script?

Description

An action consists of a pattern and a tcl script. When mmucl receives output from the mud it checks the pattern of each action to see if that pattern matches the mud's 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.

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 associated with the pattern. Up to 9 matches are supported. "%0" is the entire string matched. The special interpretation of "%" can be escaped with "\".

Action with no arguments will print out all the currently defined actions. Action with one argument will return all defined action matching the pattern given by the argument. In this case pattern should be a glob pattern.

Example

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.

Warning

Action's 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 nasty 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. Read about safe interpreters in your tcl documentation for more information.

See Also

unaction match


Home