3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

Automod logging improvements

This commit is contained in:
Dragory 2019-10-11 22:56:34 +03:00
parent 17aac769bb
commit 40af0f2359
4 changed files with 26 additions and 11 deletions

View file

@ -59,5 +59,5 @@
"BOT_ALERT": "⚠ {tmplEval(body)}",
"AUTOMOD_ALERT": "{text}",
"AUTOMOD_ACTION": "\uD83E\uDD16 Automod rule **{rule}** triggered by {userMention(user)}, actions taken: {actionsTaken}\n{matchSummary}"
"AUTOMOD_ACTION": "\uD83E\uDD16 Automod rule **{rule}** triggered by {userMention(user)}. Actions taken: **{actionsTaken}**\n{matchSummary}"
}

View file

@ -13,6 +13,7 @@ import {
SECONDS,
stripObjectToScalars,
tNullable,
verboseChannelMention,
} from "../utils";
import { decorators as d } from "knub";
import { mergeConfig } from "knub/dist/configUtils";
@ -1025,10 +1026,14 @@ export class AutomodPlugin extends ZeppelinPlugin<TConfigSchema> {
const archiveId = await this.archives.createFromSavedMessages(savedMessages, this.guild);
const baseUrl = this.knub.getGlobalConfig().url;
const archiveUrl = this.archives.getUrl(baseUrl, archiveId);
matchSummary = `Deleted messages: <${archiveUrl}>`;
matchSummary = `Matched messages: <${archiveUrl}>`;
} else if (matchedMessageIds.length === 1) {
const message = await this.savedMessages.find(matchedMessageIds[0]);
matchSummary = `Deleted message:\n${messageSummary(message)}`;
const channel = this.guild.channels.get(message.channel_id);
const channelMention = channel ? verboseChannelMention(channel) : `\`#${message.channel_id}\``;
matchSummary = `Matched message in ${channelMention} (originally posted at **${
message.posted_at
}**):\n${messageSummary(message)}`;
}
if (matchResult.type === "username") {

View file

@ -13,6 +13,9 @@ import {
stripObjectToScalars,
UnknownUser,
useMediaUrls,
verboseChannelMention,
verboseUserMention,
verboseUserName,
} from "../utils";
import DefaultLogMessages from "../data/DefaultLogMessages.json";
import moment from "moment-timezone";
@ -193,17 +196,11 @@ export class LogsPlugin extends ZeppelinPlugin<TConfigSchema> {
const memberConfig = this.getMatchingConfig({ member, userId: user.id }) || ({} as any);
if (memberConfig.ping_user) {
// Ping/mention the user
return `<@!${user.id}> (**${user.username}#${user.discriminator}**, \`${user.id}\`)`;
} else {
// No ping/mention
return `**${user.username}#${user.discriminator}** (\`${user.id}\`)`;
}
return memberConfig.ping_user ? verboseUserMention(user) : verboseUserName(user);
},
channelMention: channel => {
if (!channel) return "";
return `<#${channel.id}> (**#${channel.name}**, \`${channel.id}\`)`;
return verboseChannelMention(channel);
},
messageSummary: (msg: SavedMessage) => {
if (!msg) return "";

View file

@ -7,6 +7,7 @@ import {
Guild,
GuildAuditLog,
GuildAuditLogEntry,
GuildChannel,
Member,
MessageContent,
TextableChannel,
@ -792,3 +793,15 @@ export function messageSummary(msg: SavedMessage) {
return result;
}
export function verboseUserMention(user: User | UnknownUser): string {
return `<@!${user.id}> (**${user.username}#${user.discriminator}**, \`${user.id}\`)`;
}
export function verboseUserName(user: User | UnknownUser): string {
return `**${user.username}#${user.discriminator}** (\`${user.id}\`)`;
}
export function verboseChannelMention(channel: GuildChannel): string {
return `<#${channel.id}> (**#${channel.name}**, \`${channel.id}\`)`;
}