Add allowBlock, allowSuspend, and allowSnippets as configuration options (#498)

Co-authored-by: Miikka <2606411+Dragory@users.noreply.github.com>
cshd
Liam 2020-11-05 16:32:43 +00:00 committed by GitHub
parent 968d780e28
commit eea6a1c2b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 5 deletions

View File

@ -97,17 +97,29 @@ If enabled, staff members can delete their own replies in modmail threads with `
**Default:** `on`
If enabled, staff members can edit their own replies in modmail threads with `!edit`
#### allowBlock
**Default:** `on`
If enabled, staff members can block a user from using modmail with `!block`
#### allowSuspend
**Default:** `on`
If enabled, staff members can suspend a user from using modmail with `!suspend`
#### allowSnippets
**Default:** `on`
If enabled, staff members can use [Snippets](snippets.md)
#### allowInlineSnippets
**Default:** `on`
If enabled, snippets can be included *within* replies by wrapping the snippet's name in {{ and }}.
If `allowSnippets` is enabled, this option controls whether the snippets can be included *within* replies by wrapping the snippet's name in {{ and }}.
E.g. `!r Hello! {{rules}}`
See [inlineSnippetStart](#inlineSnippetStart) and [inlineSnippetEnd](#inlineSnippetEnd) to customize the symbols used.
#### allowChangingDisplayRole
**Default:** `on`
If enabled, moderators can change the role that's shown with their replies to any role they currently have using the `!role` command.
See [inlineSnippetStart](#inlineSnippetStart) and [inlineSnippetEnd](#inlineSnippetEnd) to customize the symbols used.
#### alwaysReply
**Default:** `off`
If enabled, all messages in modmail threads will be sent to the user without having to use `!r`.

View File

@ -215,7 +215,7 @@ class Thread {
const moderatorName = config.useNicknames && moderator.nick ? moderator.nick : moderator.user.username;
const roleName = await getModeratorThreadDisplayRoleName(moderator, this.id);
if (config.allowInlineSnippets) {
if (config.allowSnippets && config.allowInlineSnippets) {
// Replace {{snippet}} with the corresponding snippet
// The beginning and end of the variable - {{ and }} - can be changed with the config options
// config.inlineSnippetStart and config.inlineSnippetEnd

View File

@ -33,6 +33,9 @@
* @property {boolean} [rolesInThreadHeader=false]
* @property {boolean} [allowStaffEdit=true]
* @property {boolean} [allowStaffDelete=true]
* @property {boolean} [allowBlock=true]
* @property {boolean} [allowSuspend=true]
* @property {boolean} [allowSnippets=true]
* @property {boolean} [enableGreeting=false]
* @property {string} [greetingMessage]
* @property {string} [greetingAttachment]

View File

@ -173,7 +173,18 @@
"$ref": "#/definitions/customBoolean",
"default": true
},
"allowBlock": {
"$ref": "#/definitions/customBoolean",
"default": true
},
"allowSuspend": {
"$ref": "#/definitions/customBoolean",
"default": true
},
"allowSnippets": {
"$ref": "#/definitions/customBoolean",
"default": true
},
"enableGreeting": {
"$ref": "#/definitions/customBoolean",
"default": false

View File

@ -4,6 +4,7 @@ const blocked = require("../data/blocked");
const utils = require("../utils");
module.exports = ({ bot, knex, config, commands }) => {
if (! config.allowBlock) return;
async function removeExpiredBlocks() {
const expiredBlocks = await blocked.getExpiredBlocks();
const logChannel = utils.getLogChannel();

View File

@ -7,6 +7,7 @@ const whitespaceRegex = /\s/;
const quoteChars = ["'", "\""];
module.exports = ({ bot, knex, config, commands }) => {
if (! config.allowSnippets) return;
/**
* "Renders" a snippet by replacing all argument placeholders e.g. {1} {2} with their corresponding arguments.
* The number in the placeholder is the argument's order in the argument list, i.e. {1} is the first argument (= index 0)

View File

@ -6,6 +6,7 @@ const config = require("../cfg");
const {THREAD_STATUS} = require("../data/constants");
module.exports = ({ bot, knex, config, commands }) => {
if (! config.allowSuspend) return;
// Check for threads that are scheduled to be suspended and suspend them
async function applyScheduledSuspensions() {
const threadsToBeSuspended = await threads.getThreadsThatShouldBeSuspended();