In depth Chat Executor guide & entry examples

Introduction

The Intelligent Chat Executor & Modifier module modifies and or performs actions triggered by defined messages/commands using simple or complex matching techniques. It also optionally supports execution of sign text and anvil renames. It is one of the more complex modules to configure well, but this guide is here to show some examples and help!

Entry structure

Entries use the following format:

1: # entry number
  match: # text or pattern to find in chat or commands
  set-matches-as: # what to set the matched text in chat to
  execute: # the actions to execute when this entry is matched
  - action
  - action
  - etc.

These 3 nodes can be heavily customized to fit various needs:

'match:' nodes:

Match nodes determine the message or pattern to find in chat or commands.

You can prefix/start 'match:' nodes with:

  • {only_commands} to only run the match on commands

  • {only_chat} to only run the match on chat

  • {only_anvils} to run the entry on anvil renames (if the anvil listener is enabled in config.yml)

  • {only_signs} to run the entry on sign text (if the sign listener is enabled in config.yml)

If you use neither only_chat or only_commands it will match both chat and commands. When using only_anvils or only_signs the entry will solely execute on anvils or signs

You can also add:

  • {text} to specify that the match is just plain text and is not regex

  • {regex} to specify that the match is using regex

If you use neither, plain text will be defaulted to

A handy regex cheat sheet can be found here: https://medium.com/factory-mind/regex-tutorial-a-simple-cheatsheet-by-examples-649dc1c3f285

Node examples

match: {text}{only_commands}/plugins will match only the command "/plugins"

match: {regex}([123]) will match any messages in chat or commands containing the characters 1, 2, or 3

On regex matches, make sure you escape any regex symbols you want there as regular text by adding a "\" to the start of any of these: <([{^\-=$!|]})?*+.>

'set-matches-as:' nodes:

Set matches as nodes determine what to set the matched text to

Any text you type after the node will be what the matched text will be set to, however if you don't want to set the matched chat message to anything you can use one of the following:

  • {dont_modify} to not modify the players message at all, but still send it.

  • {block} to block the players message entirely.

  • {dont_notify} to not send any admin notifier message when matched (if admin notifications are enabled for the Chat Executor)

    {dont_log} to not log anything the when the entry is triggered (if logging is enabled for the Chat Executor)

These are stackable, ex. "{block}{dont_modify}{dont_log}" however, {dont_modify} and {block} must not be in the same set-as node as they conflict.

'execute:' action lists:

Execute action lists determine the actions to execute when this entry is matched

To have no actions, set to "execute: []"

To set the type of action, you must prefix/start the action with:

  • {player_msg}: to send a message to the player.

  • {console_cmd}: to run a command as the console.

  • {player_cmd}: to run a command as the player.

  • {broadcast}: to broadcast a message to all players.

To use parts of the players message in actions, you can use:

  • {arg<number>} to get the word/argument of the players message (starting from 0)

    • ex {arg1} in "FirstWord SecondWord ThirdWord" is "FirstWord", {arg2} is "SecondWord", etc.

  • {multiargs<number>} to get all the arguments/words after a particular argument/word.

    • ex {multiargs2} of "FirstWord SecondWord ThirdWord FourthWord" is "ThirdWord FourthWord"

You can use multiple {arg<number>} and {multiarg<number>}placeholders in actions. If the requested argument/word is not present, it will simply be blank.

To get the players username or displayname in actions, you can use:

  • {PLAYER} to get the players username.

  • {PLAYER_DISPLAYNAME} to get the players display name with its original colors

  • {PLAYER_DISPLAYNAME_STRIPPED} to get the players display name stripped of its original colors

Action examples

execute:
- "{broadcast}: Hi {PLAYER}!"
- "{broadcast}: The first word you typed in yoru message was {arg1}!"

The above broadcasts, "Hi" followed by the player who triggered the entries username, and then broadcasts the first word of their message that triggered the entry.

execute:
- "{console_cmd}: tell {PLAYER} this is from the console!"

The above runs the command: "tell" followed by the player who triggered the entries username, followed by "this is from the console!"

Entry examples

1 - Detect a question and answer it privately

The below example detects numerous variations of players asking for staff, blocks it, and tells them staff applications are closed. The match is regex, so it is prefixed with {regex}. Regex groups are specified with (), and sections of groups are separated by |

The below detects the following, but is not limited to:

  • "can I apply for staff?"

  • "could I have admin?"

  • "I want to apply"

entries:
  1:
    match: "{regex}(can i apply for|give me|i would like|can i have|could i have|i wanna be|i want|i want to be|i wanna apply for|can i|i want to|i wanna) (admin|staff|op|operator|mod|moderator|owner|co owner|coowner|apply)"
    set-matches-as: "{block}"
    execute:
      - "{player_msg}: &eSorry, staff applications are not open at this time."
      - "{player_msg}: &eWe will let the community know when we're looking again!"

2 - Auto reply globally to a question

You can use a similar setup as above to answer commonly asked server questions. The below match is using regex, so it is prefixed with {regex}. It's also prefixed with {only-chat} to ensure this match is only effective in global chat and not commands.

entries:
  1:
    match: "{regex}{only-chat}(is there a|what is the|whats the|can i have the|could i have the) (discord|discord server|discord link)"
    set-matches-as: "{dont_modify}{dont_notify}{dont_log}"
    execute:
      - "{broadcast}: &d{PLAYER}, the Discord server can be joined here: &fdiscord.gg/exampleLink"

3 - Modify a message but execute no actions

The below example tries to match variations of players saying the server is bad, and modifies their message to say it's good. The below match is using regex, so it is prefixed with {regex}.

entries:
  1:
    match: "{regex}this server (sucks|is lame|is trash|is boring|is not good|isn't good)"
    set-matches-as: "I love this server :D"
    execute: []

4 - Custom command outputs

You can get creative and create custom message outputs for commands, even if the player doesn't have access to it. The below example will show the player msg content to players who type /op. The regex expression will match only commands that are exactly /plugins or /pl

entries:
  1:
    match: "{regex}{only_commands}^(/plugins|/pl)$"
    set-matches-as: "{block}"
    execute:
      - "{player_msg}: &fPlugins (1): &aNone of your business >:D"

5 - Match only an exact chat message

Matching an exact chat message (excluding character case) and not text contained in the chat message is easy with regex, just use the following:

{regex}^exact text here$

{regex}^(exact phrase 1|exact phrase 2)$

Example:

entries:
  1:
    match: "{regex}^only match this whole message$"
    set-matches-as: "{block}{dont_notify}{dont_log}"
    execute:
      - "{player_msg}: Congrats, your whole message was 'only match this whole message'!"

6 - Use parts of the players message in execute actions

The below utilizes the multiargs placeholder to get all words after the 2nd word (after "repeat me:")

entries:
  1:
    match: "{text}{only_chat}repeat me:"
    set-matches-as: "{dont_modify}{dont_notify}{dont_log}"
    execute:
      - "{broadcast}: You typed: '{multiargs2}'"

The below utilizes the multiargs placeholder and the arg placeholder to get all words, and get the 8th word (after "repeat only the first word I type:")

entries:
  1:
    match: "{text}{only_chat}repeat only the first word I type:"
    set-matches-as: "{dont_modify}{dont_notify}{dont_log}"
    execute:
      - "{broadcast}: The first word after 'repeat only the first word I type:' was: '{arg8}'"

The below utilizes multiple arg placeholders to get different words from the matched message

entries:
  1:
    match: "{text}{only_chat}repeat only the first and second word I type:"
    set-matches-as: "{dont_modify}{dont_notify}{dont_log}"
    execute:
      - "{broadcast}: The first word: '{arg10}', the second word: '{arg11}'"

Last updated