New option for the moderation bot: forbid duplicate messages (#516).

This commit is contained in:
John Livingston
2024-09-10 18:59:56 +02:00
parent 651641f63c
commit 5225257bb5
11 changed files with 227 additions and 10 deletions

View File

@ -50,6 +50,12 @@ function getDefaultChannelConfigurationOptions (_options: RegisterServerOptions)
tolerance: 0,
applyToModerators: false
},
noDuplicate: {
enabled: false,
reason: '',
delay: 60,
applyToModerators: false
},
quotes: [],
commands: []
},
@ -124,6 +130,11 @@ function channelConfigurationOptionsToBotRoomConf (
handlersIds.set(id, true)
handlers.push(_getForbidSpecialCharsHandler(id, channelConfigurationOptions.bot.forbidSpecialChars))
}
if (channelConfigurationOptions.bot.noDuplicate.enabled) {
const id = 'no_duplicate'
handlersIds.set(id, true)
handlers.push(_getNoDuplicateHandler(id, channelConfigurationOptions.bot.noDuplicate))
}
channelConfigurationOptions.bot.quotes.forEach((v, i) => {
const id = 'quote_' + i.toString()
handlersIds.set(id, true)
@ -254,6 +265,23 @@ function _getForbidSpecialCharsHandler (
return handler
}
function _getNoDuplicateHandler (
id: string,
noDuplicate: ChannelConfigurationOptions['bot']['noDuplicate']
): ConfigHandler {
const handler: ConfigHandler = {
type: 'no-duplicate',
id,
enabled: true,
options: {
reason: noDuplicate.reason,
delay: noDuplicate.delay,
applyToModerators: !!noDuplicate.applyToModerators
}
}
return handler
}
function _getQuotesHandler (
id: string,
quotes: ChannelConfigurationOptions['bot']['quotes'][0]