mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 14:11:50 +00:00
logs: add excluded_message_regex option
This commit is contained in:
parent
713333f35e
commit
53742f1970
1 changed files with 18 additions and 0 deletions
|
@ -30,6 +30,7 @@ import { trimPluginDescription, ZeppelinPlugin } from "./ZeppelinPlugin";
|
||||||
import { renderTemplate, TemplateParseError } from "../templateFormatter";
|
import { renderTemplate, TemplateParseError } from "../templateFormatter";
|
||||||
import cloneDeep from "lodash.clonedeep";
|
import cloneDeep from "lodash.clonedeep";
|
||||||
import * as t from "io-ts";
|
import * as t from "io-ts";
|
||||||
|
import { TSafeRegex } from "../validatorUtils";
|
||||||
|
|
||||||
const LogChannel = t.partial({
|
const LogChannel = t.partial({
|
||||||
include: t.array(t.string),
|
include: t.array(t.string),
|
||||||
|
@ -37,6 +38,7 @@ const LogChannel = t.partial({
|
||||||
batched: t.boolean,
|
batched: t.boolean,
|
||||||
batch_time: t.number,
|
batch_time: t.number,
|
||||||
excluded_users: t.array(t.string),
|
excluded_users: t.array(t.string),
|
||||||
|
excluded_message_regex: t.array(TSafeRegex),
|
||||||
});
|
});
|
||||||
type TLogChannel = t.TypeOf<typeof LogChannel>;
|
type TLogChannel = t.TypeOf<typeof LogChannel>;
|
||||||
|
|
||||||
|
@ -148,6 +150,22 @@ export class LogsPlugin extends ZeppelinPlugin<TConfigSchema> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type === LogType.MESSAGE_DELETE && opts.excluded_message_regex && data.message.data.content) {
|
||||||
|
for (const regex of opts.excluded_message_regex) {
|
||||||
|
if (regex.test(data.message.data.content)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type === LogType.MESSAGE_EDIT && opts.excluded_message_regex && data.before.data.content) {
|
||||||
|
for (const regex of opts.excluded_message_regex) {
|
||||||
|
if (regex.test(data.before.data.content)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const message = await this.getLogMessage(type, data);
|
const message = await this.getLogMessage(type, data);
|
||||||
if (message) {
|
if (message) {
|
||||||
if (opts.batched) {
|
if (opts.batched) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue