mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 04:25:01 +00:00
Typed log functions + more
This commit is contained in:
parent
d2ac700143
commit
bed6589d48
166 changed files with 4021 additions and 869 deletions
|
@ -1,24 +1,23 @@
|
|||
import * as t from "io-ts";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { stripObjectToScalars, unique } from "../../../utils";
|
||||
import { isTruthy, stripObjectToScalars, unique } from "../../../utils";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
import { automodAction } from "../helpers";
|
||||
import { userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
|
||||
|
||||
export const LogAction = automodAction({
|
||||
configType: t.boolean,
|
||||
defaultConfig: true,
|
||||
|
||||
async apply({ pluginData, contexts, ruleName, matchResult }) {
|
||||
const safeUsers = unique(contexts.map(c => c.user))
|
||||
.filter(Boolean)
|
||||
.map(user => stripObjectToScalars(user));
|
||||
const safeUser = safeUsers[0];
|
||||
const users = unique(contexts.map(c => c.user)).filter(isTruthy);
|
||||
const user = users[0];
|
||||
const actionsTaken = Object.keys(pluginData.config.get().rules[ruleName].actions).join(", ");
|
||||
|
||||
pluginData.getPlugin(LogsPlugin).log(LogType.AUTOMOD_ACTION, {
|
||||
pluginData.getPlugin(LogsPlugin).logAutomodAction({
|
||||
rule: ruleName,
|
||||
user: safeUser,
|
||||
users: safeUsers,
|
||||
user,
|
||||
users,
|
||||
actionsTaken,
|
||||
matchSummary: matchResult.summary,
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue