From 6942507f177ee28eaafa21ac2ee5fb1f33edb186 Mon Sep 17 00:00:00 2001 From: Johnathon Tinsley Date: Tue, 31 Oct 2023 18:01:50 +0000 Subject: [PATCH 1/6] Add feature: override role name displayed to end user from config option --- src/data/cfg.jsdoc.js | 1 + src/data/cfg.schema.json | 6 ++++++ src/formatters.js | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/data/cfg.jsdoc.js b/src/data/cfg.jsdoc.js index bed89b5aa..3d4d849c8 100644 --- a/src/data/cfg.jsdoc.js +++ b/src/data/cfg.jsdoc.js @@ -77,6 +77,7 @@ * @property {boolean} [errorOnUnknownInlineSnippet=true] * @property {boolean} [allowChangingDisplayRole=true] * @property {string} [fallbackRoleName=null] + * @property {string} [overrideRoleNameDisplay] Overrides the role displayed on replies * @property {boolean} [breakFormattingForNames=true] * @property {boolean} [autoAlert=false] * @property {string} [autoAlertDelay="2m"] Delay before auto-alert kicks in. Uses the same format as timed close; for example 1m30s for 1 minute and 30 seconds. diff --git a/src/data/cfg.schema.json b/src/data/cfg.schema.json index f8be1e62e..64225e1d1 100644 --- a/src/data/cfg.schema.json +++ b/src/data/cfg.schema.json @@ -400,6 +400,12 @@ "default": null }, + "overrideRoleNameDisplay": { + "$comment": "Overrides the role displayed on replies", + "type": "string", + "default": null + }, + "breakFormattingForNames": { "$ref": "#/definitions/customBoolean", "default": true diff --git a/src/formatters.js b/src/formatters.js index b85cc8034..a19a26384 100644 --- a/src/formatters.js +++ b/src/formatters.js @@ -101,7 +101,7 @@ const bot = require("./bot"); */ const defaultFormatters = { formatStaffReplyDM(threadMessage) { - const roleName = threadMessage.role_name || config.fallbackRoleName; + const roleName = config.overrideRoleNameDisplay || threadMessage.role_name || config.fallbackRoleName; const modInfo = threadMessage.is_anonymous ? roleName : (roleName ? `(${roleName}) ${threadMessage.user_name}` : threadMessage.user_name); @@ -112,7 +112,7 @@ const defaultFormatters = { }, formatStaffReplyThreadMessage(threadMessage) { - const roleName = threadMessage.role_name || config.fallbackRoleName; + const roleName = config.overrideRoleNameDisplay || threadMessage.role_name || config.fallbackRoleName; const modInfo = threadMessage.is_anonymous ? (roleName ? `(Anonymous) (${threadMessage.user_name}) ${roleName}` : `(Anonymous) (${threadMessage.user_name})`) : (roleName ? `(${roleName}) ${threadMessage.user_name}` : threadMessage.user_name); From 63cb56275fc065c27d3c70d8804577bfb69ea5f8 Mon Sep 17 00:00:00 2001 From: Johnathon Tinsley Date: Wed, 1 Nov 2023 11:58:36 +0000 Subject: [PATCH 2/6] Document config option addition --- docs/configuration.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index 28cc7d199..d5bc29e34 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -56,7 +56,7 @@ To do that, use the same format as with "Accepts multiple values" above: ```ini greetingMessage[] = Welcome to the server! greetingMessage[] = This is the second line of the greeting. -greetingMessage[] = +greetingMessage[] = greetingMessage[] = Fourth line! With an empty line in the middle. ``` @@ -300,6 +300,13 @@ If enabled, a system message will be posted into any open threads if the user jo **Default:** `on` If enabled, a system message will be posted into any open threads if the user leaves a main server +#### overrideRoleNameDisplay +**Default:** *None* +Role name to display in all replies. This completely overrides normal role selection, all replies will contain the string entered. For esample; +```ini +overrideRoleNameDisplay = Moderator +``` + #### pingOnBotMention **Default:** `on` If enabled, the bot will mention staff (see `mentionRole` option) on the inbox server when the bot is mentioned on the main server. From 844048ef980a6b1f4a4cf90730ee18497acf30a3 Mon Sep 17 00:00:00 2001 From: Johnathon Tinsley Date: Wed, 1 Nov 2023 11:59:54 +0000 Subject: [PATCH 3/6] Typo fix --- docs/configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index d5bc29e34..3407080e4 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -302,7 +302,7 @@ If enabled, a system message will be posted into any open threads if the user le #### overrideRoleNameDisplay **Default:** *None* -Role name to display in all replies. This completely overrides normal role selection, all replies will contain the string entered. For esample; +Role name to display in all replies. This completely overrides normal role selection, all replies will contain the string entered. For example; ```ini overrideRoleNameDisplay = Moderator ``` From 95953e71183bb2517462c8a2d1384d14976b027e Mon Sep 17 00:00:00 2001 From: Johnathon Tinsley Date: Wed, 1 Nov 2023 12:01:09 +0000 Subject: [PATCH 4/6] Formatting tweak --- docs/configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index 3407080e4..17290f3d3 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -301,7 +301,7 @@ If enabled, a system message will be posted into any open threads if the user jo If enabled, a system message will be posted into any open threads if the user leaves a main server #### overrideRoleNameDisplay -**Default:** *None* +**Default:** `None` Role name to display in all replies. This completely overrides normal role selection, all replies will contain the string entered. For example; ```ini overrideRoleNameDisplay = Moderator From a4ba6818450c19cd7852b3dafcb393185a62fd8e Mon Sep 17 00:00:00 2001 From: Johnathon Tinsley Date: Wed, 1 Nov 2023 12:02:04 +0000 Subject: [PATCH 5/6] Formatting tweak again --- docs/configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index 17290f3d3..fed766ef9 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -301,7 +301,7 @@ If enabled, a system message will be posted into any open threads if the user jo If enabled, a system message will be posted into any open threads if the user leaves a main server #### overrideRoleNameDisplay -**Default:** `None` +**Default:** `None` Role name to display in all replies. This completely overrides normal role selection, all replies will contain the string entered. For example; ```ini overrideRoleNameDisplay = Moderator From 2ed9c71a69d007a4f06ead845cb200fe20792390 Mon Sep 17 00:00:00 2001 From: Johnathon Tinsley Date: Wed, 1 Nov 2023 13:07:57 +0000 Subject: [PATCH 6/6] Documentation fixes per review --- docs/configuration.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index fed766ef9..26aaea688 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -56,7 +56,7 @@ To do that, use the same format as with "Accepts multiple values" above: ```ini greetingMessage[] = Welcome to the server! greetingMessage[] = This is the second line of the greeting. -greetingMessage[] = +greetingMessage[] = greetingMessage[] = Fourth line! With an empty line in the middle. ``` @@ -302,10 +302,8 @@ If enabled, a system message will be posted into any open threads if the user le #### overrideRoleNameDisplay **Default:** `None` -Role name to display in all replies. This completely overrides normal role selection, all replies will contain the string entered. For example; -```ini -overrideRoleNameDisplay = Moderator -``` +Role name to display in all replies. This completely overrides normal role selection, all replies will contain the string entered. For example; `overrideRoleNameDisplay = Moderator` + #### pingOnBotMention **Default:** `on`