New option for the moderation bot: forbid duplicate messages (#516).
This commit is contained in:
@ -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]
|
||||
|
Reference in New Issue
Block a user