From 53742f197042d5c6c3a3d735a8f68728397de189 Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Fri, 11 Oct 2019 23:39:36 +0300 Subject: [PATCH] logs: add excluded_message_regex option --- src/plugins/Logs.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/plugins/Logs.ts b/src/plugins/Logs.ts index c8135961..5ef324a5 100644 --- a/src/plugins/Logs.ts +++ b/src/plugins/Logs.ts @@ -30,6 +30,7 @@ import { trimPluginDescription, ZeppelinPlugin } from "./ZeppelinPlugin"; import { renderTemplate, TemplateParseError } from "../templateFormatter"; import cloneDeep from "lodash.clonedeep"; import * as t from "io-ts"; +import { TSafeRegex } from "../validatorUtils"; const LogChannel = t.partial({ include: t.array(t.string), @@ -37,6 +38,7 @@ const LogChannel = t.partial({ batched: t.boolean, batch_time: t.number, excluded_users: t.array(t.string), + excluded_message_regex: t.array(TSafeRegex), }); type TLogChannel = t.TypeOf; @@ -148,6 +150,22 @@ export class LogsPlugin extends ZeppelinPlugin { } } + 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); if (message) { if (opts.batched) {