Rules
Rules are the backbone of Modegator's automation engine. They allow you to define an Event-Condition-Action (ECA) flow. When a specific event occurs, Modegator evaluates the provided conditions, and if they match, it executes a set of actions.
Event Triggers
Every rule must listen to a specific event. Modegator natively supports the following events:
PostSubmitCommentSubmitPostReportCommentReportPostUpdateCommentUpdateModMail
Conditions
The conditions array dictates whether a rule's actions should run by evaluating logic nodes against the triggering event.
Advanced Condition Evaluation
Modegator's condition evaluator supports advanced logical grouping and dynamic array matching:
Logical Grouping
Conditions can be nested using logical operator blocks. By default, the top-level array acts as an implicit all_of (meaning all conditions must pass), so you only need to use explicit blocks when building OR logic.
Example 1: Implicit all_of (AND Logic)
conditions:
- field: "author_karma"
operator: "<"
value: 50
- field: "author_age_days"
operator: "<"
value: 7
Example 2: Explicit any_of (OR Logic)
conditions:
- any_of:
- field: "author_karma"
operator: "<"
value: 50
- field: "author_age_days"
operator: "<"
value: 7
Example 3: Complex Nested Matching (Regex arrays + Logic)
conditions:
- any_of:
- field: "post_title"
operator: "regex"
value: ["buy.*crypto", "free.*followers"]
- all_of:
- field: "author_karma"
operator: "<"
value: 10
- field: "post_domain"
operator: "=="
value: "shady-link.com"
Array Matching
For the ==, !=, contains, and regex operators, you can provide an array of values instead of a single string or number. The engine evaluates the array dynamically:
==: Acts as an "IN" operator. Passes if the actual value exactly matches any item in the array.!=: Acts as a "NOT IN" operator. Passes if the actual value matches none of the items in the array.contains: Passes if any string in the array is a substring of the actual value.regex: Evaluates each regex pattern in the array. Passes if any pattern matches.
Dynamic Field Resolution
The field property itself is resolved dynamically using Modegator's placeholder engine before the condition is evaluated. This allows you to evaluate user-specific or dynamic keys (e.g., field: "counter_warnings_{{author}}").
Case Insensitivity
All string comparisons (including contains and regex matching) are performed case-insensitively by default.
Allowed Fields Reference
The following fields can be evaluated dynamically within any rule condition block. Every field strictly enforces its associated data type during execution.
Author Fields
| Field | Type | Description |
|---|---|---|
author_name | string | The username of the user who triggered the event. |
author_karma | number | The total numeric karma score of the author. |
author_age_days | number | The age of the author's account in days. |
author_is_banned | boolean | true if the author is currently banned in the subreddit. |
author_is_mod | boolean | true if the author is a moderator of the subreddit. |
author_is_approved | boolean | true if the author is an approved submitter. |
author_has_user_flair | string | The text of the user's assigned flair. |
author_has_mod_note | boolean | true if the user has any existing Mod Notes on their profile. |
author_mod_note_label | string | The text label of the user's most recent Mod Note (e.g., SPAM_WARNING). |
Post Fields
| Field | Type | Description |
|---|---|---|
post_title | string | The title of the post. |
post_body | string | The text body of the post. |
post_domain | string | The domain of the link (if the post is a link submission). |
post_domain_tag | string | The custom text label (e.g., Under Review, Approved) assigned to this post's domain in the Domain Tracker database. |
post_score | number | The current upvote score of the post. |
post_report_count | number | The number of reports the post has received. |
post_link_type | string | The type of post submission. Either 'link' (an external URL post) or 'self' (a text/self-post, including gallery and poll posts). |
post_is_nsfw | boolean | true if the post is marked Not Safe For Work. |
post_is_spoiler | boolean | true if the post is marked as a spoiler. |
post_flair_text | string | The text of the post's assigned flair. |
Comment Fields
| Field | Type | Description |
|---|---|---|
comment_body | string | The text content of the comment. |
comment_score | number | The current upvote score of the comment. |
comment_is_top_level | boolean | true if the comment is a direct reply to the post (not nested). |
comment_report_count | number | The number of reports the comment has received. |
ModMail Fields
| Field | Type | Description |
|---|---|---|
modmail_subject | string | The subject line of the ModMail conversation. |
modmail_body | string | The body text of the most recent ModMail message. |
modmail_body_length | number | The character length of the ModMail body text. |
Custom State Fields
| Field | Type | Description |
|---|---|---|
counter_[key] | number | Queries the dynamic numeric value of a custom Redis counter stored under [key] (e.g., counter_warnings_{{author}}). |
custom_[key] | string | Queries the string value of a custom Redis entry stored under [key] (e.g., custom_last_violation). |
Allowed Operators
==(Equals)!=(Not Equals)<,<=,>,>=(Numerical Comparisons)contains(Substring Match)regex(Regular Expression)
Note: All string comparisons are case-insensitive by default.
Rule Example
Here is an example of an automated rule filtering new accounts posting links:
rules:
- name: "Ban new link-posting accounts"
trigger:
event: "PostSubmit"
conditions:
- field: "author_age_days"
operator: "<"
value: 7
- field: "author_karma"
operator: "<"
value: 50
- field: "post_link_type"
operator: "=="
value: "link"
actions:
- type: "remove_post"
spam: true
- type: "ban_user"
duration: "permanent"
reason: "Spam account"
Fallback Actions (Optional)
You can define a fallback_actions block which executes if the primary conditions are NOT met. This is useful for building simple "if/else" logic.
