automod: Edit support and edit-reflag prevention
This commit is contained in:
parent
37704069f1
commit
1108a83ea5
1 changed files with 14 additions and 0 deletions
|
@ -237,6 +237,8 @@ export class AutomodPlugin extends ZeppelinPlugin<TConfigSchema, ICustomOverride
|
|||
protected cooldownManager: CooldownManager;
|
||||
|
||||
protected onMessageCreateFn;
|
||||
protected actionedMessageIds: string[];
|
||||
protected actionedMessageMax = 50;
|
||||
|
||||
protected savedMessages: GuildSavedMessages;
|
||||
protected archives: GuildArchives;
|
||||
|
@ -348,6 +350,8 @@ export class AutomodPlugin extends ZeppelinPlugin<TConfigSchema, ICustomOverride
|
|||
|
||||
this.onMessageCreateFn = msg => this.onMessageCreate(msg);
|
||||
this.savedMessages.events.on("create", this.onMessageCreateFn);
|
||||
this.savedMessages.events.on("update", this.onMessageCreateFn);
|
||||
this.actionedMessageIds = [];
|
||||
}
|
||||
|
||||
protected getModActions(): ModActionsPlugin {
|
||||
|
@ -365,6 +369,8 @@ export class AutomodPlugin extends ZeppelinPlugin<TConfigSchema, ICustomOverride
|
|||
protected onUnload() {
|
||||
this.unloaded = true;
|
||||
this.savedMessages.events.off("create", this.onMessageCreateFn);
|
||||
this.savedMessages.events.off("update", this.onMessageCreateFn);
|
||||
this.actionedMessageIds = [];
|
||||
clearInterval(this.recentActionClearInterval);
|
||||
clearInterval(this.recentSpamClearInterval);
|
||||
clearInterval(this.recentNicknameChangesClearInterval);
|
||||
|
@ -1481,6 +1487,7 @@ export class AutomodPlugin extends ZeppelinPlugin<TConfigSchema, ICustomOverride
|
|||
*/
|
||||
protected onMessageCreate(msg: SavedMessage) {
|
||||
if (msg.is_bot) return;
|
||||
if (this.actionedMessageIds.includes(msg.id)) return;
|
||||
|
||||
this.automodQueue.add(async () => {
|
||||
if (this.unloaded) return;
|
||||
|
@ -1504,6 +1511,13 @@ export class AutomodPlugin extends ZeppelinPlugin<TConfigSchema, ICustomOverride
|
|||
if (!savedMsg) return;
|
||||
|
||||
await this.applyActionsOnMatch(rule, matchResult);
|
||||
|
||||
// Add message ID to actioned messages to prevent alert spam on small edits
|
||||
this.actionedMessageIds.push(msg.id);
|
||||
while (this.actionedMessageIds.length > this.actionedMessageMax) {
|
||||
this.actionedMessageIds.shift();
|
||||
}
|
||||
|
||||
break; // Don't apply multiple rules to the same message
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue