mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 22:21:51 +00:00
automod: add affects_bots
This commit is contained in:
parent
a0fa21f0f5
commit
cb4beacf8a
2 changed files with 9 additions and 3 deletions
|
@ -260,6 +260,10 @@ export class AutomodPlugin extends ZeppelinPlugin<TConfigSchema, ICustomOverride
|
||||||
rule["enabled"] = true;
|
rule["enabled"] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rule["affects_bots"] == null) {
|
||||||
|
rule["affects_bots"] = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Loop through the rule's triggers
|
// Loop through the rule's triggers
|
||||||
if (rule["triggers"]) {
|
if (rule["triggers"]) {
|
||||||
for (const trigger of rule["triggers"]) {
|
for (const trigger of rule["triggers"]) {
|
||||||
|
@ -1509,7 +1513,6 @@ export class AutomodPlugin extends ZeppelinPlugin<TConfigSchema, ICustomOverride
|
||||||
* Run automod actions on new messages
|
* Run automod actions on new messages
|
||||||
*/
|
*/
|
||||||
protected onMessageCreate(msg: SavedMessage) {
|
protected onMessageCreate(msg: SavedMessage) {
|
||||||
if (msg.is_bot) return;
|
|
||||||
if (this.actionedMessageIds.includes(msg.id)) return;
|
if (this.actionedMessageIds.includes(msg.id)) return;
|
||||||
|
|
||||||
this.automodQueue.add(async () => {
|
this.automodQueue.add(async () => {
|
||||||
|
@ -1524,6 +1527,8 @@ export class AutomodPlugin extends ZeppelinPlugin<TConfigSchema, ICustomOverride
|
||||||
channelId: msg.channel_id,
|
channelId: msg.channel_id,
|
||||||
});
|
});
|
||||||
for (const [name, rule] of Object.entries(config.rules)) {
|
for (const [name, rule] of Object.entries(config.rules)) {
|
||||||
|
if (msg.is_bot && !rule.affects_bots) continue;
|
||||||
|
|
||||||
const matchResult = await this.matchRuleToMessage(rule, msg);
|
const matchResult = await this.matchRuleToMessage(rule, msg);
|
||||||
if (matchResult) {
|
if (matchResult) {
|
||||||
// Make sure the message still exists in our database when we try to apply actions on it.
|
// Make sure the message still exists in our database when we try to apply actions on it.
|
||||||
|
@ -1552,8 +1557,6 @@ export class AutomodPlugin extends ZeppelinPlugin<TConfigSchema, ICustomOverride
|
||||||
*/
|
*/
|
||||||
@d.event("guildMemberAdd")
|
@d.event("guildMemberAdd")
|
||||||
protected onMemberJoin(_, member: Member) {
|
protected onMemberJoin(_, member: Member) {
|
||||||
if (member.user.bot) return;
|
|
||||||
|
|
||||||
this.automodQueue.add(async () => {
|
this.automodQueue.add(async () => {
|
||||||
if (this.unloaded) return;
|
if (this.unloaded) return;
|
||||||
|
|
||||||
|
@ -1568,6 +1571,8 @@ export class AutomodPlugin extends ZeppelinPlugin<TConfigSchema, ICustomOverride
|
||||||
const config = this.getConfigForMember(member);
|
const config = this.getConfigForMember(member);
|
||||||
|
|
||||||
for (const [name, rule] of Object.entries(config.rules)) {
|
for (const [name, rule] of Object.entries(config.rules)) {
|
||||||
|
if (member.user.bot && !rule.affects_bots) continue;
|
||||||
|
|
||||||
const spamMatch = await this.matchOtherSpamInRule(rule, member.id);
|
const spamMatch = await this.matchOtherSpamInRule(rule, member.id);
|
||||||
if (spamMatch) {
|
if (spamMatch) {
|
||||||
await this.applyActionsOnMatch(rule, spamMatch);
|
await this.applyActionsOnMatch(rule, spamMatch);
|
||||||
|
|
|
@ -302,6 +302,7 @@ export const Rule = t.type({
|
||||||
enabled: t.boolean,
|
enabled: t.boolean,
|
||||||
name: t.string,
|
name: t.string,
|
||||||
presets: tNullable(t.array(t.string)),
|
presets: tNullable(t.array(t.string)),
|
||||||
|
affects_bots: t.boolean,
|
||||||
triggers: t.array(
|
triggers: t.array(
|
||||||
t.type({
|
t.type({
|
||||||
match_words: tNullable(MatchWordsTrigger),
|
match_words: tNullable(MatchWordsTrigger),
|
||||||
|
|
Loading…
Add table
Reference in a new issue