diff --git a/config/servers.example.js b/config/servers.example.js index c927e7c..cf9a232 100644 --- a/config/servers.example.js +++ b/config/servers.example.js @@ -65,6 +65,8 @@ module.exports = [ USE_KILL_FEED: true, KILL_FEED_DELAY: 5, KILL_FEED_CHANNEL_ID: '806479539110674472', + KILL_FEED_MESSAGE_IDENTIFIER: ' got killed by ', + KILL_FEED_REMOVE_IDENTIFIER: false, // Leaderboard config OVERALL_RANKING_STAT: 'KILLS', diff --git a/src/modules/delayed-kill-feed.js b/src/modules/delayed-kill-feed.js index 89f633c..1063efe 100644 --- a/src/modules/delayed-kill-feed.js +++ b/src/modules/delayed-kill-feed.js @@ -8,17 +8,22 @@ const checkIsDelayedKillFeedMsg = async (msg) => { author, cleanContent } = msg; - const isKillMsg = cleanContent.indexOf(' got killed by ') >= 0; - if (!isKillMsg) return false; - for await (const cfg of serverConfig) { const { USE_KILL_FEED, KILL_FEED_DELAY, KILL_FEED_CHANNEL_ID, CFTOOLS_WEBHOOK_CHANNEL_ID, - CFTOOLS_WEBHOOK_USER_ID + CFTOOLS_WEBHOOK_USER_ID, + KILL_FEED_MESSAGE_IDENTIFIER, + KILL_FEED_REMOVE_IDENTIFIER } = cfg; + const isKillMsg = cleanContent.indexOf( + KILL_FEED_MESSAGE_IDENTIFIER + ?? ' got killed by ' + ) >= 0; + if (!isKillMsg) continue; + const isTargetChannel = channelId === CFTOOLS_WEBHOOK_CHANNEL_ID; const isTargetUser = CFTOOLS_WEBHOOK_USER_ID === ( process.env.NODE_ENV === 'production' @@ -36,7 +41,11 @@ const checkIsDelayedKillFeedMsg = async (msg) => { // Send the notification await new Promise((resolve) => { setTimeout(async () => { - const feedMsg = await webhookTargetChannel.send(cleanContent); + const feedMsg = await webhookTargetChannel.send( + KILL_FEED_REMOVE_IDENTIFIER + ? cleanContent.replaceAll(KILL_FEED_MESSAGE_IDENTIFIER, '') + : cleanContent + ); resolve(feedMsg); }, KILL_FEED_DELAY * 1000); });