Skip to content

Moderation

Tommaso Ornato edited this page Sep 6, 2023 · 17 revisions

Only moderators may set AutoMod rules and only for communities where they are a mod themselves.

Example:
Bob is a mod in c/memes. Bob is allowed to enable the AutoMod and set its rules in c/memes.
However Bob is NOT a moderator in c/general, so he won't be able to set any rules in that community.

Prerequisites

Before any AutoMod configuration rule can be submitted, the bot needs to be a moderator in the target community. As a pre-release measure, it will be necessary to manually comment on the target community from the AutoMod's account and manually appoint it as a moderator. This process will be automated in further releases.

Interacting with the bot

Interaction happens through Lemmy DMs, accessible through the "Send Message" button (not "Send Secure Message"!) on the bot's profile. immagine

Configurations should be set up in the form of JSON objects. The content of the object will be discussed in the syntax paragraph.

Once an object containing one or more rules has been written, it should be pasted in the message box without any further formatting. The bot will then process it and reply to the message with either an error message or a confirmation. Error messages will be discussed in the error handling paragraph. immagine

Syntax

The syntax of configurations follows a strict set of rules to unambiguously highlight what is a valid configuration and what isn't.

Currently, the AutoMod allows four configuration options:

  • comment.json, dictates the removal of comments
  • post.json, dictates the removal of posts
  • exception.json, lists exceptions to the two aforementioned rules
  • mention.json, describes commands available to the moderators to easily "pin" and "lock" posts

Each of these configurations has to follow a JSON schema, available in the repository. It is advisable to write new rules in a code editor like Visual Studio Code, as it will automatically check for any errors in the configuration as it's being written. An online editor is also available at this link (requires a GitHub account).

Various examples of valid configurations are available in the lemmy-automoderator-examples repository.

All rules include a $schema field, used internally to validate the configuration and a rule field, describing the kind of rule (can be one of comment,post,exception,mention.

Comment

A Comment rule prescribes the automated removal of a comment, based on its content.

{
    "$schema": "https://raw.githubusercontent.com/ornato-t/lemmy-automoderator/master/src/schemas/comment.json",
    "rule": "comment",
    "community": "memes",
    "match": "pizza",
    "type": "exact",
    "whitelist_exempt": false,
    "mod_exempt": false,
    "message": "Your comment has been removed because discussions about pizza are prohibited in this community",
    "removal_reason": "Said the word 'pizza'"
}

This rule removes all comments containing the word "pizza" posted in the community c/memes. The bot will then reply to the removed comment explaining that it was removed because discussion about pizza are prohibited. Lastly, it will report the removal in the modlog giving "Said the word 'pizza'" as a removal reason. This rule will be valid for all users, including whitelisted users and moderators.

Keys

  • community: string, community where the rule will be active.
  • match: string, content to be removed. Depending on the value of type it should be either a string or a Regular Expression.
  • type: string, either "regex" or "exact". Type of filter applied in match. If the filter is set to "regex", match will be treated as a Regular Expression; if set to "exact" all comments containing the string specified in match will be removed.
  • whitelist_exempt: boolean, either true or false. Set to true if whitelisted users should be exempt from the rule. See Exception for more information on the whitelist.
  • mod_exempt: boolean, either true or false. Set to true if community moderators should be exempt from the rule.
  • message: either string or null. The message with which the bot will reply to the removed content. If set to null no reply will be sent.
  • removal_reason: either string or null. The removal reason which will appear in the modlog. If set to null the reason will be left empty.

Note: when type is set to "exact", the search will NOT be CaSe SeNsItIvE. In other words, comments including the word "pizza" will get removed, but comments including the word "Pizza" will NOT.

Additional examples

Bad words

{
    "$schema": "https://raw.githubusercontent.com/ornato-t/lemmy-automoderator/master/src/schemas/comment.json",
    "rule": "comment",
    "community": "general",
    "match": "/stink|fudge/",
    "type": "regex",
    "whitelist_exempt": true,
    "mod_exempt": false,
    "message": "Watch your language!",
    "removal_reason": "Said a bad word"
}

This rule removes all comments containing either the word "stink" or the word "fudge" posted in the c/general community. When it does so, it also warns telling them to watch their language and specifices in the modlog that the user has said a bad word. Whitelisted users are immune to this rule, so they will be able to use the words "stink" and fudge" freely, however moderators are not, so their comments will be removed.
This example uses a match based on a Regular Expression.

Prequel posting

{
    "$schema": "https://raw.githubusercontent.com/ornato-t/lemmy-automoderator/master/src/schemas/comment.json",
    "rule": "comment",
    "community": "starwars",
    "match": "/high ground/i",
    "type": "regex",
    "whitelist_exempt": false,
    "mod_exempt": true,
    "message": "Only the mods can quote the Prequels",
    "removal_reason": "Prequel posting"
}

This rule removes all comments containing the string "high ground", case insensitive. If the user is a moderator in the community their comment will NOT be removed, otherwise it will, even if the user is among those whitelisted in the community.

Post

Exception

Mention

Error handling

Clone this wiki locally