8.4. Gags

Now that the basic usage of triggers has been explained, let us see some more advanced features.

In KildClient, gags are just a special kind of trigger with the "gag" flag activated, and they behave just like other triggers, with the exception that the line that matched the pattern does not get printed in the screen. It is possible to have a gag that executes an action when triggered, just like with non-gag triggers, or it can be a simple gag, which prevents the line from being printed but does nothing else.

To specify that a trigger is a gag when it is created, just check the Omit (gag) from output checkbox when creating the trigger.

Let's create a simple gag to omit all that is said by Joe, a very silly and annoying player:

Example 8.5. A simple gag
  • Pattern: ^Joe chats

  • Action: /$world->echonl("Joe said something silly here.")

  • Omit (gag) from output: Checked


This trigger is a gag, and whenever a line starting with "Joe chats" is received, it will not be printed. Instead, the code specified in the action will be executed, and that code will print a message that tells you that Joe said something, but does not tell what, so you do not need to worry.

That is good, but can get even better. We do not need to know that Joe said something, it would be better if we could ignore him altogether. And we can. It is not necessary to specify an action for a gag trigger. In this case, nothing will be done, but the matched line will not be printed. So our example becomes:

Example 8.6. A gag with no action
  • Pattern: ^Joe chats

  • Omit (gag) from output: Checked


The action has simply been omitted, but the check box that specifies that we are creating a gag trigger remains, naturally.

Sometimes you want to change the way a line is displayed, such as rearranging the information so that it appears in another way. The way to do that is with a gag, and an action that outputs the modified line. Heres a simple example that changes the way a hypothetical chat channel is displayed:

Example 8.7. Rewriting a line with gags
  • Pattern: ^(.*) chats, '(.*)'

  • Action: /$world->echonl("[Chat] $_[1]: $_[2]")

  • Omit (gag) from output: Checked


The Omit (gag) from output check box only controls whether the line is displayed in the screen or not. If you have logging enabled (see Chapter 14, Logging the Output), a the line that matched a trigger with that option checked will be written in the log file normally. If you want the line to be omitted from the log file, you must set also the Omit (gag) from log file check box. If it is set, then the line will not be written to the log file. Note that the two attributes are independent: you can gag the line from the screen, from the log file, from both or from neither.