A trigger-rule is a sequence of commands (the Trigger-Action) that is named by a word or phrase (the Trigger-Phrase). The trigger-action is executed when the trigger-phrase is used; this is described as the trigger-rule firing.
Trigger-rules may be external or internal. External rules are fired when their trigger-phrase is spoken in open chat by someone authorized to fire the trigger; in addition, the sub can fire their own authorized external rules via chat on channel 98. Internal rules are fired via one of the execute family of commands. Since these commands may be included within the action of another trigger-rule, this allows one trigger-action to fire other triggers.
A trigger-rule is defined to the Mesmerizer via the following syntax on a command channel:
<Trigger-phrase> = <Trigger-action>
The presence of an unquoted "=" identifies this as a trigger definition; everything to the left of the "=" is taken as the trigger-phrase, and everything to the right is taken as the trigger-action. The first word of the trigger action may optionally be a key or one of the following keywords to specify who can fire the trigger:
- me - only the person defining the trigger may fire it. This is the default
- subject - only the subject may fire the trigger
- other - anyone other than the subject may fire the trigger
- any - anyone may fire the trigger
- internal - the trigger is internal, and may only be fired via an execute-family command or an event.
Events are triggers that are generated internally by the Mesmerizer, usually in response to some external activity. They will be covered in a future post.
The "=" syntax is used to define triggers. The following table describes the other commands used to manipulate defined triggers, as well as the execute commands that are used to fire internal triggers.
| Command | Params | Description |
|---|---|---|
| list | 0 | List the defined triggers via a menu that allows you to move through the defined triggers and delete individual ones |
| backup | 0 | Emit a string of commands that save the Mesmerizer's state. The primary purpose of this command is to transfer settings to a new Mesmerizer, but it can also be a convenient way to see all the defined triggers in a single list |
| delete | 1 | Delete a trigger. <p1> is the number of the trigger (as shown by list or backup). The remaining triggers will be renumbered |
| execute | 1 | Execute a trigger. <p1> is the trigger-phrase of the desired trigger-rule. The execute family of commands is the only way to fire an internal trigger |
| executeif | 2 | Conditionally execute a trigger. <p2> is the trigger-phrase of the desired trigger-rule; <p1> is an expression. <p2> will be fired only if <p1> evaluates to true |
| executein | 2 | Schedules a trigger event. <p2> is the trigger-phrase of the desired trigger-rule; <p1> is an interval. <p2> will be fired after the specified interval has passed |
| executeevery | 2 | Schedules a repeating trigger event. <p2> is the trigger-phrase of the desired trigger-rule; <p1> is an interval. <p2> will be fired each time the interval passes |
| showsched | 0 | Lists the scheduled events (created via executein and executeevery). Each scheduled event has a key that can be used with the cancel command to cancel the scheduled event |
| cancel | 1 | Delete a scheduled event. <p1> is the key of the event to be canceled |
The executeevery and executein commands take an interval parameter. This is a string that specifies a time duration. The easiest way to describe an interval is to give examples:
- "1s" - 1 second
- "1m" - 1 minute or 60 seconds
- "1m1s" - 1 minute and 1 second, or 61 seconds
- "2h30m" - 2 hours and 30 minutes, or 150 minutes
- "1d" - 1 day or 24 hours
No comments:
Post a Comment