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` **Default:** `on`
If enabled, staff members can edit their own replies in modmail threads with `!edit` 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 #### allowInlineSnippets
**Default:** `on` **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}}` E.g. `!r Hello! {{rules}}`
See [inlineSnippetStart](#inlineSnippetStart) and [inlineSnippetEnd](#inlineSnippetEnd) to customize the symbols used.
#### allowChangingDisplayRole #### allowChangingDisplayRole
**Default:** `on` **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. 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 #### alwaysReply
**Default:** `off` **Default:** `off`
If enabled, all messages in modmail threads will be sent to the user without having to use `!r`. 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 moderatorName = config.useNicknames && moderator.nick ? moderator.nick : moderator.user.username;
const roleName = await getModeratorThreadDisplayRoleName(moderator, this.id); const roleName = await getModeratorThreadDisplayRoleName(moderator, this.id);
if (config.allowInlineSnippets) { if (config.allowSnippets && config.allowInlineSnippets) {
// Replace {{snippet}} with the corresponding snippet // Replace {{snippet}} with the corresponding snippet
// The beginning and end of the variable - {{ and }} - can be changed with the config options // The beginning and end of the variable - {{ and }} - can be changed with the config options
// config.inlineSnippetStart and config.inlineSnippetEnd // config.inlineSnippetStart and config.inlineSnippetEnd

View File

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

View File

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

View File

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

View File

@ -7,6 +7,7 @@ const whitespaceRegex = /\s/;
const quoteChars = ["'", "\""]; const quoteChars = ["'", "\""];
module.exports = ({ bot, knex, config, commands }) => { 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. * "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) * 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"); const {THREAD_STATUS} = require("../data/constants");
module.exports = ({ bot, knex, config, commands }) => { module.exports = ({ bot, knex, config, commands }) => {
if (! config.allowSuspend) return;
// Check for threads that are scheduled to be suspended and suspend them // Check for threads that are scheduled to be suspended and suspend them
async function applyScheduledSuspensions() { async function applyScheduledSuspensions() {
const threadsToBeSuspended = await threads.getThreadsThatShouldBeSuspended(); const threadsToBeSuspended = await threads.getThreadsThatShouldBeSuspended();