3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 04:25:01 +00:00

More Automod updates

This commit is contained in:
Dragory 2020-07-28 21:51:58 +03:00
parent e359fc46b2
commit 07da88b7cb
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
13 changed files with 88 additions and 28 deletions

View file

@ -1,10 +1,23 @@
import * as t from "io-ts";
import { automodAction } from "../helpers";
import { LogsPlugin } from "../../Logs/LogsPlugin";
import { LogType } from "../../../data/LogType";
import { stripObjectToScalars } from "../../../utils";
export const LogAction = automodAction({
configType: t.boolean,
async apply({ pluginData, contexts, actionConfig }) {
// TODO: Everything
async apply({ pluginData, contexts, ruleName, matchResult }) {
const safeUsers = contexts.map(c => c.user && stripObjectToScalars(c.user)).filter(Boolean);
const safeUser = safeUsers[0];
const actionsTaken = Object.keys(pluginData.config.get().rules[ruleName].actions);
pluginData.getPlugin(LogsPlugin).log(LogType.AUTOMOD_ACTION, {
rule: ruleName,
user: safeUser,
users: safeUsers,
actionsTaken,
matchSummary: matchResult.summary,
});
},
});