Skip to content

Commit 97ff482

Browse files
committed
Post a report for low flags
1 parent 0f7fa35 commit 97ff482

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/feeds/AutoModManager.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class AutoModManager {
3939
}
4040

4141
private addToLastReports(mods: IModWithFlags[]) {
42-
this.lastReports = [mods, ...this.lastReports].filter((v, i) => i <= 9);
42+
this.lastReports = [mods, ...this.lastReports.filter((v, i) => i <= 9)];
4343
}
4444

4545
private constructor(client: ClientExt) {
@@ -102,16 +102,17 @@ export class AutoModManager {
102102
results.push(await analyseMod(mod, this.AutoModRules, user))
103103
}
104104
this.addToLastReports(results);
105-
const concerns = results.filter(m => (m.flags.high.length) !== 0);
106-
if (!concerns.length) {
105+
// const concerns = results.filter(m => (m.flags.high.length) !== 0);
106+
// if (!concerns.length) {
107+
if (!results.length) {
107108
logMessage('No mods with concerns found.')
108109
return;
109110
}
110111
else {
111112
try {
112-
logMessage('Reporting mods:', concerns.map(c => `${c.mod.name} - ${c.flags.high.join(', ')} - ${c.flags.low.join(', ')}`));
113-
await PublishToSlack(flagsToSlackMessage(concerns));
114-
await PublishToDiscord(flagsToDiscordEmbeds(concerns))
113+
logMessage('Reporting mods:', results.map(c => `${c.mod.name} - ${c.flags.high.join(', ')} - ${c.flags.low.join(', ')}`));
114+
await PublishToSlack(flagsToSlackMessage(results));
115+
await PublishToDiscord(flagsToDiscordEmbeds(results));
115116
}
116117
catch(err) {
117118
logMessage('Error posting automod to Discord or Slack', err, true)
@@ -159,6 +160,7 @@ function flagsToSlackMessage(data: IModWithFlags[]): ISlackMessage {
159160
text: `<${modLink}|${input.mod.name}> uploaded by <${userLink}|${input.mod.uploader?.name}>\n`+
160161
`<!date^${uploadTime}^Posted {time_secs} {date_short_pretty}|${input.mod.createdAt}>\n\n`+
161162
`<!date^${joinTime}^User Joined {time_secs} {date_short_pretty}|${input.mod.uploader?.joined}>\n\n`+
163+
`*Game:* ${input.mod.game?.name ?? 'Unknown Game'}`+
162164
`*Flags:*\n${[...input.flags.high.map(f => `- ${f} [HIGH]`), ...input.flags.low.map(f => `- ${f} [LOW]`)].join('\n')}\n`+
163165
`<https://www.nexusmods.com/admin/members/ban?ban_action=1&user_id=${userId}|Ban> | <https://www.nexusmods.com/admin/members/ipuse?uid=${userId}|IP History>`
164166
},
@@ -170,13 +172,16 @@ function flagsToSlackMessage(data: IModWithFlags[]): ISlackMessage {
170172
}
171173
})
172174

175+
// Are there any concerns that require a ping?
176+
const pingable: boolean = data.filter(m => (m.flags.high.length) > 0).length > 0;
177+
173178
return {
174179
blocks: [
175180
{
176181
type: 'header',
177182
text: {
178183
type: 'plain_text',
179-
text: 'Mod spam detected'
184+
text: pingable ? 'Mod spam detected' : 'Automod report'
180185
}
181186
},
182187
{
@@ -186,13 +191,13 @@ function flagsToSlackMessage(data: IModWithFlags[]): ISlackMessage {
186191
{
187192
type: 'divider'
188193
},
189-
{
194+
pingable ? {
190195
type: 'section',
191196
text: {
192197
type: 'mrkdwn',
193198
text: 'FAO <!subteam^SC2Q2J1DF>'
194199
}
195-
}
200+
} : { type: 'divider' }
196201
]
197202
}
198203
}
@@ -226,9 +231,12 @@ function flagsToDiscordEmbeds(data: IModWithFlags[]): RESTPostAPIWebhookWithToke
226231

227232
return embed.toJSON()
228233
}
234+
235+
// Are there any concerns that require a ping?
236+
const pingable: boolean = data.filter(m => (m.flags.high.length) > 0).length > 0;
229237

230238
return {
231-
content: "# Mod Spam Detected\n@here", //role pings <@&1308814010602487839> <@&520360132631199744>
239+
content: pingable ? "# Mod Spam Detected\n@here" : "# Automod Detections", //role pings <@&1308814010602487839> <@&520360132631199744>
232240
username: "Automod",
233241
embeds: data.map(modEmbeds)
234242
}

0 commit comments

Comments
 (0)