Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger, condition and action system #65

Open
anna328p opened this issue Apr 7, 2021 · 1 comment
Open

Trigger, condition and action system #65

anna328p opened this issue Apr 7, 2021 · 1 comment
Labels
enhancement New feature or request modules Related to a module
Projects

Comments

@anna328p
Copy link
Collaborator

anna328p commented Apr 7, 2021

  • Triggers can be created per-message, per-channel, or per-server.
  • Triggers can be of different types:
    • Message text
    • Reaction
    • Custom bot command
  • Conditions can test if the invoking user has certain roles or other attributes.
  • Actions can do one of the following:
    • Send a message
    • Assign a role arbitrarily
    • Assign a role from a rolegroup

Reaction roles will use this system internally.

@anna328p anna328p added enhancement New feature or request modules Related to a module labels Apr 7, 2021
@anna328p anna328p added this to To do in Backlog via automation Apr 9, 2021
@anna328p
Copy link
Collaborator Author

anna328p commented Apr 10, 2021

Triggers

A trigger can be created by a user with the proper permissions.

A trigger's scope determines where it applies:

  • Server-wide: the event can happen anywhere on the server.
  • Channel: the event must happen in a specific channel.
  • Message: the event must be related to a specific message (reaction, reply)

Triggers have a persistence setting:

  • Persistent: stays active until it is removed.
  • Temporary: stays active for a certain time, then is deleted.
  • Oneshot: activates once, then is deleted.

Oneshot triggers only persist for 24 hours. Old oneshot and temporary triggers are regularly cleaned up.

Conditions

A trigger can have one of several conditions:

  • Command: message beginning with the server's prefix.
  • Starts with: message begins with the given string.
  • Contains: message contains the given string.
  • Matches: message is the same as the given string.
  • Regex: message matches the given regex.
  • Reaction Add: a certain reaction is added to a message.
  • Reaction Remove: a certain reaction is removed from a message.
  • Interval: the trigger activates once each time a given interval of time passes.
  • Voice Join: a user joins the voice channel.
    • Voice Leave: a user leaves the voice channel.

Each of these conditions takes one parameter, which can be a string, a regex, or a duration.

Actions

Triggers are linked to actions. Each trigger may only be linked to one action. However, actions can be chained.

Blacklist

Users can be blacklisted from activating triggers in a given channel or server.

Caching

Triggers are cached per-server.

Limits

A server has a limited number of persistent, temporary, and custom triggers. This number will be different for each type of trigger.

Actions

Actions are separate from triggers. Multiple triggers can link to one action.

There are several types of actions:

  • Message: send a given message in a given channel.
    • The message can be chosen randomly from a list.
    • The message can reference the content of the triggering message.
  • Delete Message: deletes the message that activated the trigger.
  • React: add a reaction to a message.
  • Role: add a role to the user activating the trigger.
    • There is an optional rolegroup parameter. If it is set, maximum group role counts will be checked.
  • Purge: remove all messages sent by the user from a given channel.
  • Create Trigger: create a oneshot trigger with given parameters.
    • The new trigger can be linked to the message that invoked this action.
    • This action can only create oneshot triggers.

Actions typically have two parameters. The meaning of these parameters is specific to the type of action.

An action can have a chain attribute. After an action completes, it calls the action specified in its chain attribute, if one exists. Loops are not allowed: when an action is called, the bot keeps track of every action executed in the chain, and if there is an attempt to call the same action again, the operation aborts.

Actions cannot create new actions or activate triggers.

Limits

Servers have a limited number of actions, but this number is much greater than the trigger limit.

Action chains have a maximum length.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request modules Related to a module
Projects
Backlog
In progress
Development

No branches or pull requests

1 participant