Skip to content

Commit

Permalink
Merge pull request #786 from Kirrus-Indiestone/roles
Browse files Browse the repository at this point in the history
Add feature: override role name displayed to end user from config option
  • Loading branch information
Dragory authored Oct 14, 2024
2 parents 28db594 + 2ed9c71 commit 47a4fa9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,11 @@ 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 example; `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.
Expand Down
1 change: 1 addition & 0 deletions src/data/cfg.jsdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,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.
Expand Down
6 changes: 6 additions & 0 deletions src/data/cfg.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,12 @@
"default": null
},

"overrideRoleNameDisplay": {
"$comment": "Overrides the role displayed on replies",
"type": "string",
"default": null
},

"breakFormattingForNames": {
"$ref": "#/definitions/customBoolean",
"default": true
Expand Down
4 changes: 2 additions & 2 deletions src/formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 47a4fa9

Please sign in to comment.