phase 9 notification toggles (per-alert, per-category, master; default-disabled)
This commit is contained in:
@@ -6,6 +6,11 @@ const { EmbedBuilder } = require('discord.js');
|
||||
const { CONFIG, parseThresholdString } = require('../config');
|
||||
const { shouldFireCooldownEscalating, clearEscalating } = require('./patternStore');
|
||||
const { enqueueSend } = require('./channelQueue');
|
||||
const { assertKeysRegistered } = require('./notificationRegistry');
|
||||
const { isEnabled } = require('./notificationEnabled');
|
||||
|
||||
const CHAT_ALERT_KEYS = ['chat_messages', 'chat_time'];
|
||||
assertKeysRegistered('chatAlertChecker', CHAT_ALERT_KEYS);
|
||||
|
||||
// channelId → { lastStaffMessageAt, unrespondedCount, lastAlertAt }
|
||||
const chatState = new Map();
|
||||
@@ -54,7 +59,7 @@ async function runChatAlertChecks(client) {
|
||||
|
||||
for (const [channelId, state] of chatState) {
|
||||
// Message count threshold
|
||||
if (state.unrespondedCount >= CONFIG.CHAT_ALERT_MESSAGE_COUNT) {
|
||||
if (isEnabled('chat_messages') && state.unrespondedCount >= CONFIG.CHAT_ALERT_MESSAGE_COUNT) {
|
||||
const cooldownKey = `chat:messages:${channelId}`;
|
||||
if (shouldFireCooldownEscalating(cooldownKey, chatMessageThresholdsMs) !== null) {
|
||||
const embed = new EmbedBuilder()
|
||||
@@ -72,7 +77,7 @@ async function runChatAlertChecks(client) {
|
||||
|
||||
// Time threshold
|
||||
const hoursSinceStaff = (Date.now() - state.lastStaffMessageAt.getTime()) / 3600000;
|
||||
if (hoursSinceStaff >= CONFIG.CHAT_ALERT_HOURS_WITHOUT_RESPONSE && state.unrespondedCount > 0) {
|
||||
if (isEnabled('chat_time') && hoursSinceStaff >= CONFIG.CHAT_ALERT_HOURS_WITHOUT_RESPONSE && state.unrespondedCount > 0) {
|
||||
const cooldownKey = `chat:time:${channelId}`;
|
||||
if (shouldFireCooldownEscalating(cooldownKey, chatTimeThresholdsMs) !== null) {
|
||||
const embed = new EmbedBuilder()
|
||||
|
||||
Reference in New Issue
Block a user