From eed88e933977ecc09e30d803ae12d9be4e3e146d Mon Sep 17 00:00:00 2001 From: John Livingston Date: Thu, 21 Sep 2023 16:09:50 +0200 Subject: [PATCH] UI WIP. --- client/@types/global.d.ts | 12 +- .../common/configuration/templates/channel.ts | 116 ++++++++++++++---- languages/en.yml | 33 +++-- server/lib/configuration/bot.ts | 2 +- 4 files changed, 124 insertions(+), 39 deletions(-) diff --git a/client/@types/global.d.ts b/client/@types/global.d.ts index 2d28729c..ed734f6b 100644 --- a/client/@types/global.d.ts +++ b/client/@types/global.d.ts @@ -49,11 +49,19 @@ declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_REASON_LABEL: s declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_REASON_DESC: string declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_REGEXP_LABEL: string 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_COMMAND_LABEL: string +declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_DESC: string +declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_CMD_LABEL: string +declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_CMD_DESC: string +declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_MESSAGE_LABEL: string +declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_MESSAGE_DESC: string declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_LABEL: string declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_DESC: string +declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_DESC2: string declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_DELAY_LABEL: string declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_DELAY_DESC: string -declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_COMMAND_LABEL: string -declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_COMMAND_DESC: string declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_BANNED_JIDS_LABEL: string declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_BOT_NICKNAME: string +declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_FOR_MORE_INFO: string diff --git a/client/common/configuration/templates/channel.ts b/client/common/configuration/templates/channel.ts index a87498dc..b69f8d9b 100644 --- a/client/common/configuration/templates/channel.ts +++ b/client/common/configuration/templates/channel.ts @@ -49,6 +49,9 @@ async function renderConfigurationChannel ( target=_blank class="orange-button peertube-button-link" >${helpIcon}` + const helpButtonForbiddenWords = helpButton + const helpButtonQuotes = helpButton + const helpButtonCommands = helpButton const view = { title: await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_TITLE), @@ -70,16 +73,28 @@ async function renderConfigurationChannel ( forbiddenWordsRegexpDesc: await peertubeHelpers.translate( LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_REGEXP_DESC ), + forbiddenWordsApplyToModerators: await peertubeHelpers.translate( + LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_APPLYTOMODERATORS_LABEL + ), + forbiddenWordsApplyToModeratorsDesc: await peertubeHelpers.translate( + LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_APPLYTOMODERATORS_DESC + ), quoteLabel: await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_LABEL), quoteDesc: await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_DESC), + quoteDesc2: await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_DESC2), quoteDelayLabel: await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_DELAY_LABEL), quoteDelayDesc: await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_DELAY_DESC), - quoteCommandLabel: await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_COMMAND_LABEL), - quoteCommandDesc: await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_COMMAND_DESC), + commandLabel: await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_LABEL), + commandDesc: await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_DESC), + commandCmdLabel: await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_CMD_LABEL), + commandCmdDesc: await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_CMD_DESC), + commandMessageLabel: await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_MESSAGE_LABEL), + commandMessageDesc: await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_MESSAGE_DESC), // bannedJIDs: await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_BANNED_JIDS_LABEL), save: await peertubeHelpers.translate(LOC_SAVE), cancel: await peertubeHelpers.translate(LOC_CANCEL), botNickname: await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_BOT_NICKNAME), + moreInfo: await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FOR_MORE_INFO), forbiddenWordsArray: [0, 1, 2].map(count => { return { displayNumber: count + 1, @@ -87,7 +102,14 @@ async function renderConfigurationChannel ( displayHelp: count === 0 } }), - quotesArray: [0, 1, 2].map(count => { + quotesArray: [0].map(count => { + return { + displayNumber: count + 1, + fieldNumber: count, + displayHelp: count === 0 + } + }), + cmdsArray: [0, 1, 2].map(count => { return { displayNumber: count + 1, fieldNumber: count, @@ -95,6 +117,9 @@ async function renderConfigurationChannel ( } }), helpButton, + helpButtonForbiddenWords, + helpButtonCommands, + helpButtonQuotes, channelConfiguration } @@ -106,6 +131,7 @@ async function renderConfigurationChannel ( {{channelConfiguration.channel.displayName}} {{channelConfiguration.channel.name}} + {{{helpButton}}}

{{description}}

@@ -146,8 +172,8 @@ async function renderConfigurationChannel (

{{forbiddenWords}} #{{displayNumber}}

{{#displayHelp}} -

{{forbiddenWordsDesc}}

- {{{helpButton}}} +

{{forbiddenWordsDesc}} {{moreInfo}}

+ {{{HelpButtonForbiddenWords}}} {{/displayHelp}}
@@ -176,6 +202,17 @@ async function renderConfigurationChannel (

{{forbiddenWordsRegexpDesc}}

+
+ +

{{forbiddenWordsApplyToModeratorsDesc}}

+

{{quoteLabel}} #{{displayNumber}}

{{#displayHelp}} -

{{quoteDesc}}

- {{{helpButton}}} +

{{quoteDesc}} {{moreInfo}}

+ {{{helpButtonQuotes}}} {{/displayHelp}}
- + class="form-control" + >{{ + #channelConfiguration.configuration.TODO + }}{{.}}\n{{ + /channelConfiguration.configuration.TODO + }} +

{{quoteDesc2}}

{{quoteDelayDesc}}

-
- - -

{{quoteCommandDesc}}

-
{{/quotesArray}} + + {{#cmdsArray}}{{! iterating on cmdsArray to display N fields }} +
+
+

{{commandLabel}} #{{displayNumber}}

+ {{#displayHelp}} +

{{commandDesc}} {{moreInfo}}

+ {{{helpButtonCommands}}} + {{/displayHelp}} +
+
+
+ + +

{{commandCmdDesc}}

+
+
+ + +

{{commandMessageDesc}}

+
+
+
+ {{/cmdsArray}}
diff --git a/languages/en.yml b/languages/en.yml index b493f0ff..bda2c764 100644 --- a/languages/en.yml +++ b/languages/en.yml @@ -319,7 +319,6 @@ livechat_configuration_channel_forbidden_words_label: "Forbidden words or expres livechat_configuration_channel_forbidden_words_desc: | You can configure some words that will be automatically moderated by the bot (messages containing such words will be instantly deleted). You can also add an optional reason that will be displayed at the place of deleted messages. - For more information about how to configure this feature, please refer to the documentation by clicking on the help button. Several examples are provided on the documentation page. livechat_configuration_channel_forbidden_words_desc2: | One word or expression per line. If you put multiple words on one line, it will only match messages containing the whole sequence. @@ -327,20 +326,32 @@ livechat_configuration_channel_forbidden_words_reason_label: "Reason" livechat_configuration_channel_forbidden_words_reason_desc: "Reason to display besides deleted messages" livechat_configuration_channel_forbidden_words_regexp_label: "Consider as regular expressions" livechat_configuration_channel_forbidden_words_regexp_desc: "By checking this option, you can use regular expressions." -livechat_configuration_channel_quote_label: "Pre-recorded message" +livechat_configuration_channel_forbidden_words_applytomoderators_label: "Also moderate messages from moderators" +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_quote_label: "Pre-recorded messages" livechat_configuration_channel_quote_desc: | You can configure several pre-recorded messages. - These messages will be sent by the bot every X minutes and/or when a chat user uses the corresponding command (for example "!help", where "help is the command name"). - You can for example make the bot sent some sponsoring information every 5 minutes, or when a user types "!sponsor". - For more information about how to configure this feature, please refer to the documentation by clicking on the help button. + These messages will be sent by the bot every X minutes. + You can for example make the bot sent some sponsoring information every 5 minutes. +livechat_configuration_channel_quote_desc2: | + One message per line. + If multiple messages, it will pick one randomly every X minutes. livechat_configuration_channel_quote_delay_label: "Send every X minutes" livechat_configuration_channel_quote_delay_desc: | The bot will post the message every X minutes. - Set to 0 if you don't want the bot to send the message periodically. -livechat_configuration_channel_quote_command_label: "Bot command" -livechat_configuration_channel_quote_command_desc: | - A command on which the bot will respond. - For example if you set "help", the bot will respond to messages starting with "!help". - Left empty if you don't want the bot to respond to commands. +livechat_configuration_channel_command_label: "Bot command" +livechat_configuration_channel_command_desc: | + You can configure the bot to respond to commands. + A command is a message starting with a "!", like for example "!help" that calls the "help" command. +livechat_configuration_channel_command_cmd_label: "Command" +livechat_configuration_channel_command_cmd_desc: | + The command, without the starting "!". For example "help", "sponsor", ... +livechat_configuration_channel_command_message_label: "Message" +livechat_configuration_channel_command_message_desc: | + The message to send. Can contain "{{NICK}}" that will be replaced by the user's nickname. +livechat_configuration_channel_for_more_info: | + For more information about how to configure this feature, please refer to the documentation by clicking on the help button. livechat_configuration_channel_banned_jids_label: "Banned users and patterns" livechat_configuration_channel_bot_nickname: "Bot nickname" \ No newline at end of file diff --git a/server/lib/configuration/bot.ts b/server/lib/configuration/bot.ts index 046a22c9..95c112d6 100644 --- a/server/lib/configuration/bot.ts +++ b/server/lib/configuration/bot.ts @@ -190,7 +190,7 @@ class BotConfiguration { // Note: using localhost, and not currentProsody.host, because it does not always resolve correctly service: 'xmpp://localhost:' + port }, - name: 'Moderator', + name: 'Sepia', logger: 'ConsoleLogger', log_level: isDebugMode(this.options) ? 'debug' : 'info' }