From 1c4e693af60c74215dbc3fbf5cbd5eeeebe04ecb Mon Sep 17 00:00:00 2001 From: Daniel Matthies Date: Wed, 21 Apr 2021 18:08:04 -0600 Subject: Fixing death message false positives --- src/Config.ts | 2 +- src/MinecraftHandler.ts | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/Config.ts b/src/Config.ts index 5a1417d..8b10801 100644 --- a/src/Config.ts +++ b/src/Config.ts @@ -32,6 +32,7 @@ export interface Config { WEBHOOK: string REGEX_SERVER_PREFIX: string REGEX_MATCH_CHAT_MC: string + REGEX_DEATH_MESSAGE: string REGEX_IGNORED_CHAT: string DEBUG: boolean @@ -42,5 +43,4 @@ export interface Config { SHOW_PLAYER_ADVANCEMENT: boolean SHOW_PLAYER_DEATH: boolean SHOW_PLAYER_ME: boolean - DEATH_KEY_WORDS: string[] } diff --git a/src/MinecraftHandler.ts b/src/MinecraftHandler.ts index 452784a..faf1828 100644 --- a/src/MinecraftHandler.ts +++ b/src/MinecraftHandler.ts @@ -113,15 +113,14 @@ class MinecraftHandler { return { username: serverUsername, message: `**${username}** ${rest}` } } } else if (this.config.SHOW_PLAYER_DEATH) { - for (let word of this.config.DEATH_KEY_WORDS){ - if (data.includes(word)){ - if (this.config.DEBUG) { - console.log( - `[DEBUG] A player died. Matched key word "${word}"` - ) - } - return { username: serverUsername, message: logLine } + const death_msg_re = new RegExp(this.config.REGEX_DEATH_MESSAGE) + const death_msg_match = logLine.match(death_msg_re) + + if (death_msg_match) { + if (this.config.DEBUG) { + console.log(`[DEBUG] A player died. Matched on "${death_msg_match[1]}"`) } + return { username: serverUsername, message: logLine } } } -- cgit 1.4.1 From ccc8e3d182ebd05173c6a243c590eb78cff54a66 Mon Sep 17 00:00:00 2001 From: Daniel Matthies Date: Mon, 17 May 2021 12:58:30 -0600 Subject: Add config deprecation notice --- src/Shulker.ts | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/Shulker.ts b/src/Shulker.ts index 4c79c78..d9373ee 100644 --- a/src/Shulker.ts +++ b/src/Shulker.ts @@ -8,6 +8,8 @@ class Shulker { discordClient: DiscordClient handler: Handler + readonly deprecatedConfigs: string[] = ['DEATH_KEY_WORDS']; + constructor() { } @@ -20,6 +22,12 @@ class Shulker { return false } + for (let option of this.deprecatedConfigs) { + if (this.config.hasOwnProperty(option)) { + console.log('[WARN] Using deprecated config option ' + option + '. Check README.md for current options.') + } + } + if (this.config.USE_WEBHOOKS) { console.log('[INFO] Using Discord WebHooks to send messages') } else { -- cgit 1.4.1 ea&follow=1'>Use CURL_PREFIX to set flagsJune McEnroe 2019-09-05Add titleJune McEnroe 2019-09-04Add Avorter n'est pas tuerJune McEnroe 2019-08-29Unset executable on shell scriptsJune McEnroe 2019-08-29Add long-missing setopt to bin.7June McEnroe 2019-08-29Add editJune McEnroe