Add `fallbackRoleName` option. Don't include "Moderator" in role-less anonymous replies unless `fallbackRoleName` is set.

cshd
Dragory 2020-10-21 23:24:45 +03:00
parent 0e2135943f
commit 2d13f88ccc
No known key found for this signature in database
GPG Key ID: 5F387BA66DF8AAC1
5 changed files with 25 additions and 6 deletions

View File

@ -12,6 +12,9 @@ Please report any bugs you encounter by [creating a GitHub issue](https://github
* The symbols used can be changed with the `inlineSnippetStart` and `inlineSnippetEnd` options * The symbols used can be changed with the `inlineSnippetStart` and `inlineSnippetEnd` options
* This feature can be disabled by setting `allowInlineSnippets = off` in your config * This feature can be disabled by setting `allowInlineSnippets = off` in your config
* By default, the bot will refuse to send a reply with an unknown inline snippet. To disable this behavior, set `errorOnUnknownInlineSnippet = off`. * By default, the bot will refuse to send a reply with an unknown inline snippet. To disable this behavior, set `errorOnUnknownInlineSnippet = off`.
* New option: `fallbackRoleName`
* Sets the role name to display in moderator replies if the moderator doesn't have a hoisted role
* Unless `fallbackRoleName` is set, anonymous replies without a role will no longer display "Moderator:" at the beginning of the message
* Plugins can now also be installed from NPM modules * Plugins can now also be installed from NPM modules
* Example: `plugins[] = npm:some-plugin-package` * Example: `plugins[] = npm:some-plugin-package`
* Fix occasional bug with expiring blocks where the bot would send the expiry message multiple times * Fix occasional bug with expiring blocks where the bot would send the expiry message multiple times

View File

@ -177,6 +177,10 @@ When enabled, the bot will send a greeting DM to users that join the main server
When enabled, the bot will refuse to send any reply with an unknown inline snippet. When enabled, the bot will refuse to send any reply with an unknown inline snippet.
See [allowInlineSnippets](#allowInlineSnippets) for more details. See [allowInlineSnippets](#allowInlineSnippets) for more details.
#### fallbackRoleName
**Default:** *None*
Role name to display in moderator replies if the moderator doesn't have a hoisted role
#### greetingAttachment #### greetingAttachment
**Default:** *None* **Default:** *None*
Path to an image or other attachment to send as a greeting. Requires `enableGreeting` to be enabled. Path to an image or other attachment to send as a greeting. Requires `enableGreeting` to be enabled.

View File

@ -61,6 +61,7 @@
* @property {string} [inlineSnippetEnd="}}"] * @property {string} [inlineSnippetEnd="}}"]
* @property {boolean} [errorOnUnknownInlineSnippet=true] * @property {boolean} [errorOnUnknownInlineSnippet=true]
* @property {boolean} [allowChangingDisplayedRole=true] * @property {boolean} [allowChangingDisplayedRole=true]
* @property {string} [fallbackRoleName=null]
* @property {string} [logStorage="local"] * @property {string} [logStorage="local"]
* @property {object} [logOptions] * @property {object} [logOptions]
* @property {string} logOptions.attachmentDirectory * @property {string} logOptions.attachmentDirectory

View File

@ -341,6 +341,11 @@
"default": true "default": true
}, },
"fallbackRoleName": {
"type": "string",
"default": null
},
"logStorage": { "logStorage": {
"type": "string", "type": "string",
"default": "local" "default": "local"

View File

@ -100,19 +100,25 @@ const moment = require("moment");
*/ */
const defaultFormatters = { const defaultFormatters = {
formatStaffReplyDM(threadMessage) { formatStaffReplyDM(threadMessage) {
const roleName = threadMessage.role_name || config.fallbackRoleName;
const modInfo = threadMessage.is_anonymous const modInfo = threadMessage.is_anonymous
? (threadMessage.role_name ? threadMessage.role_name : "Moderator") ? roleName
: (threadMessage.role_name ? `(${threadMessage.role_name}) ${threadMessage.user_name}` : threadMessage.user_name); : (roleName ? `(${roleName}) ${threadMessage.user_name}` : threadMessage.user_name);
return `**${modInfo}:** ${threadMessage.body}`; return modInfo
? `**${modInfo}:** ${threadMessage.body}`
: threadMessage.body;
}, },
formatStaffReplyThreadMessage(threadMessage) { formatStaffReplyThreadMessage(threadMessage) {
const roleName = threadMessage.role_name || config.fallbackRoleName;
const modInfo = threadMessage.is_anonymous const modInfo = threadMessage.is_anonymous
? `(Anonymous) (${threadMessage.user_name}) ${threadMessage.role_name || "Moderator"}` ? (roleName ? `(Anonymous) (${threadMessage.user_name}) ${roleName}` : `(Anonymous) (${threadMessage.user_name})`)
: (threadMessage.role_name ? `(${threadMessage.role_name}) ${threadMessage.user_name}` : threadMessage.user_name); : (roleName ? `(${roleName}) ${threadMessage.user_name}` : threadMessage.user_name);
let result = `**${modInfo}:** ${threadMessage.body}`; let result = modInfo
? `**${modInfo}:** ${threadMessage.body}`
: threadMessage.body;
if (config.threadTimestamps) { if (config.threadTimestamps) {
const formattedTimestamp = utils.getTimestamp(threadMessage.created_at); const formattedTimestamp = utils.getTimestamp(threadMessage.created_at);