diff --git a/client/@types/global.d.ts b/client/@types/global.d.ts
index d0f60662..a4bc56c1 100644
--- a/client/@types/global.d.ts
+++ b/client/@types/global.d.ts
@@ -55,6 +55,8 @@ declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_REGEXP_LABEL: s
declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_REGEXP_DESC: string
declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_APPLYTOMODERATORS_LABEL: string
declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_APPLYTOMODERATORS_DESC: string
+declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_COMMENTS_LABEL: string
+declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_COMMENTS_DESC: string
declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_LABEL: string
declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_DESC: string
declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_CMD_LABEL: string
diff --git a/client/common/configuration/templates/channel.mustache b/client/common/configuration/templates/channel.mustache
index 402ed1d8..5e7e7840 100644
--- a/client/common/configuration/templates/channel.mustache
+++ b/client/common/configuration/templates/channel.mustache
@@ -101,6 +101,16 @@
/>
{{forbiddenWordsReasonDesc}}
+
{{/forbiddenWordsArray}}
diff --git a/client/common/configuration/templates/channel.ts b/client/common/configuration/templates/channel.ts
index 3fdeceea..bccdcb49 100644
--- a/client/common/configuration/templates/channel.ts
+++ b/client/common/configuration/templates/channel.ts
@@ -91,6 +91,12 @@ async function fillLabels (
view.forbiddenWordsApplyToModeratorsDesc = await peertubeHelpers.translate(
LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_APPLYTOMODERATORS_DESC
)
+ view.forbiddenWordsComments = await peertubeHelpers.translate(
+ LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_COMMENTS_LABEL
+ )
+ view.forbiddenWordsCommentsDesc = await peertubeHelpers.translate(
+ LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_COMMENTS_DESC
+ )
view.quoteLabel = await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_LABEL)
view.quoteDesc = await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_DESC)
view.quoteDesc2 = await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_DESC2)
diff --git a/client/common/configuration/templates/logic/channel.ts b/client/common/configuration/templates/logic/channel.ts
index 26479eec..a78e36ee 100644
--- a/client/common/configuration/templates/logic/channel.ts
+++ b/client/common/configuration/templates/logic/channel.ts
@@ -43,7 +43,8 @@ async function getConfigurationChannelViewData (
joinedEntries: fw.entries.join('\n'),
regexp: !!fw.regexp,
applyToModerators: fw.applyToModerators,
- reason: fw.reason
+ reason: fw.reason,
+ comments: fw.comments
})
}
// Ensuring we have at least N blocks:
@@ -57,7 +58,8 @@ async function getConfigurationChannelViewData (
joinedEntries: '',
regexp: false,
applyToModerators: false,
- reason: ''
+ reason: '',
+ comments: ''
})
continue
}
@@ -231,6 +233,7 @@ async function vivifyConfigurationChannel (
const regexp = data.get('forbidden_words_regexp_' + i.toString())
const applyToModerators = data.get('forbidden_words_applytomoderators_' + i.toString())
const reason = data.get('forbidden_words_reason_' + i.toString())?.toString()
+ const comments = data.get('forbidden_words_comments_' + i.toString())?.toString()
const fw: ChannelConfigurationOptions['bot']['forbiddenWords'][0] = {
entries,
applyToModerators: !!applyToModerators,
@@ -239,6 +242,9 @@ async function vivifyConfigurationChannel (
if (reason) {
fw.reason = reason
}
+ if (comments) {
+ fw.comments = comments
+ }
channelConfigurationOptions.bot.forbiddenWords.push(fw)
}
diff --git a/languages/en.yml b/languages/en.yml
index 2acfeb83..54f502e3 100644
--- a/languages/en.yml
+++ b/languages/en.yml
@@ -336,6 +336,10 @@ livechat_configuration_channel_forbidden_words_applytomoderators_label: "Also m
livechat_configuration_channel_forbidden_words_applytomoderators_desc: |
By default, moderator messages will not be deleted when containing forbidden words.
By checking this option, messages from moderators will also be deleted.
+livechat_configuration_channel_forbidden_words_comments_label: "Comments"
+livechat_configuration_channel_forbidden_words_comments_desc: |
+ You can add here some comments about this rule, to remember how and why you created it.
+ These comments are purely indicative, and have no influence on the bot's behavior.
livechat_configuration_channel_quote_label: "Pre-recorded messages"
livechat_configuration_channel_quote_desc: |
You can configure several pre-recorded messages.
diff --git a/server/lib/configuration/channel/sanitize.ts b/server/lib/configuration/channel/sanitize.ts
index 86920a96..8dcec66d 100644
--- a/server/lib/configuration/channel/sanitize.ts
+++ b/server/lib/configuration/channel/sanitize.ts
@@ -105,6 +105,19 @@ function _readStringArray (data: any, f: string): string[] {
return result
}
+function _readMultiLineString (data: any, f: string): string {
+ if (!(f in data)) {
+ return ''
+ }
+ if (typeof data[f] !== 'string') {
+ throw new Error('Invalid data type for field ' + f)
+ }
+ // Removing control characters.
+ // eslint-disable-next-line no-control-regex
+ const s = (data[f] as string).replace(/[\u0000-\u001F\u007F-\u009F]/g, '')
+ return s
+}
+
async function _readRegExpArray (data: any, f: string): Promise {
// Note: this function can instanciate a lot of RegExp.
// To avoid freezing the server, we make it async, and will validate each regexp in a separate tick.
@@ -153,12 +166,14 @@ async function _readForbiddenWords (botData: any): Promise
quotes: Array<{
messages: string[]
diff --git a/support/documentation/content/en/documentation/user/streamers/bot/forbidden_words.md b/support/documentation/content/en/documentation/user/streamers/bot/forbidden_words.md
index f0198191..b40a875b 100644
--- a/support/documentation/content/en/documentation/user/streamers/bot/forbidden_words.md
+++ b/support/documentation/content/en/documentation/user/streamers/bot/forbidden_words.md
@@ -52,3 +52,7 @@ By checking this option, each line of the "{{% livechat_label livechat_configura
## {{% livechat_label livechat_configuration_channel_forbidden_words_reason_label %}}
{{% livechat_label livechat_configuration_channel_forbidden_words_reason_desc %}}
+
+## {{% livechat_label livechat_configuration_channel_forbidden_words_comments_label %}}
+
+{{% livechat_label livechat_configuration_channel_forbidden_words_comments_desc %}}