diff --git a/server/chat-plugins/abuse-monitor.ts b/server/chat-plugins/abuse-monitor.ts index 734934497d..20845c045e 100644 --- a/server/chat-plugins/abuse-monitor.ts +++ b/server/chat-plugins/abuse-monitor.ts @@ -634,6 +634,40 @@ export const commands: Chat.ChatCommands = { } this.sendReplyBox(buf); }, + cm: 'compare', + async compare(target) { + checkAccess(this); + const [base, against] = Utils.splitFirst(target, ',').map(f => f.trim()); + if (!(base && against)) return this.parse(`/help abusemonitor`); + const colors: Record = { + '0': 'Purple', + '1': 'DodgerBlue', + '2': 'Red', + }; + const baseResponse = await classifier.classify(base) || {}; + const againstResponse = await new Promise | null>(resolve => { + // bit of a hack, but this has to be done so rate limits don't get hit + setTimeout(() => { + resolve(classifier.classify(against)); + }, 500); + }) || {}; + let buf = Utils.html`Compared scores for "${base}" `; + buf += `(1) `; + buf += Utils.html`and "${against}" (2):
`; + for (const [k, val] of Object.entries(baseResponse)) { + const max = Math.max(val, againstResponse[k]); + const num = val === againstResponse[k] ? '0' : max === val ? '1' : '2'; + buf += `• ${k}: ${num} `; + if (num === '0') { + buf += `(${max})`; + } else { + buf += `(${max} vs ${(max === val ? againstResponse : baseResponse)[k]})`; + } + buf += `
`; + } + this.runBroadcast(); + return this.sendReplyBox(buf); + }, toggle(target) { checkAccess(this); if (this.meansYes(target)) {