3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-16 14:11:50 +00:00

Fix logMessage variable not working in automod alert

This commit is contained in:
Dragory 2021-08-20 20:31:36 +03:00
parent bd2c51691a
commit 0b28215208
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -16,10 +16,12 @@ import {
tNormalizedNullOptional, tNormalizedNullOptional,
isTruthy, isTruthy,
verboseChannelMention, verboseChannelMention,
validateAndParseMessageContent,
} from "../../../utils"; } from "../../../utils";
import { LogsPlugin } from "../../Logs/LogsPlugin"; import { LogsPlugin } from "../../Logs/LogsPlugin";
import { automodAction } from "../helpers"; import { automodAction } from "../helpers";
import { TemplateSafeUser, userToTemplateSafeUser } from "../../../utils/templateSafeObjects"; import { TemplateSafeUser, userToTemplateSafeUser } from "../../../utils/templateSafeObjects";
import { messageIsEmpty } from "../../../utils/messageIsEmpty";
export const AlertAction = automodAction({ export const AlertAction = automodAction({
configType: t.type({ configType: t.type({
@ -66,7 +68,7 @@ export const AlertAction = automodAction({
actionsTaken, actionsTaken,
matchSummary: matchResult.summary, matchSummary: matchResult.summary,
messageLink: theMessageLink, messageLink: theMessageLink,
logMessage: logMessage?.content, logMessage: validateAndParseMessageContent(logMessage)?.content,
}), }),
); );
} catch (err) { } catch (err) {
@ -80,6 +82,13 @@ export const AlertAction = automodAction({
throw err; throw err;
} }
if (messageIsEmpty(rendered)) {
pluginData.getPlugin(LogsPlugin).logBotAlert({
body: `Tried to send alert with an empty message for automod rule ${ruleName}`,
});
return;
}
try { try {
await createChunkedMessage( await createChunkedMessage(
channel, channel,