New option for the moderation bot: forbid duplicate messages (#516).
This commit is contained in:
@ -68,6 +68,7 @@ export class ChannelDetailsService {
|
||||
if (botConf.enabled) {
|
||||
propertiesError['bot.nickname'] = []
|
||||
propertiesError['bot.forbidSpecialChars.tolerance'] = []
|
||||
propertiesError['bot.noDuplicate.delay'] = []
|
||||
|
||||
if (/[^\p{L}\p{N}\p{Z}_-]/u.test(botConf.nickname ?? '')) {
|
||||
propertiesError['bot.nickname'].push(ValidationErrorType.WrongFormat)
|
||||
@ -88,6 +89,21 @@ export class ChannelDetailsService {
|
||||
}
|
||||
}
|
||||
|
||||
if (botConf.noDuplicate.enabled) {
|
||||
const noDuplicateDelay = channelConfigurationOptions.bot.noDuplicate.delay
|
||||
if (
|
||||
(typeof noDuplicateDelay !== 'number') ||
|
||||
isNaN(noDuplicateDelay)
|
||||
) {
|
||||
propertiesError['bot.noDuplicate.delay'].push(ValidationErrorType.WrongType)
|
||||
} else if (
|
||||
noDuplicateDelay < 0 ||
|
||||
noDuplicateDelay > 24 * 3600
|
||||
) {
|
||||
propertiesError['bot.noDuplicate.delay'].push(ValidationErrorType.NotInRange)
|
||||
}
|
||||
}
|
||||
|
||||
for (const [i, fw] of botConf.forbiddenWords.entries()) {
|
||||
for (const v of fw.entries) {
|
||||
propertiesError[`bot.forbiddenWords.${i}.entries`] = []
|
||||
|
Reference in New Issue
Block a user