From 9ddddf070b9917f48439b5f6d5253415daa784a8 Mon Sep 17 00:00:00 2001 From: Xayanide Date: Fri, 20 May 2022 22:23:04 +0800 Subject: [PATCH 1/9] refactor(plugins#HostSkipper): improve texts and error messages --- src/plugins/HostSkipper.ts | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/plugins/HostSkipper.ts b/src/plugins/HostSkipper.ts index be94178e..746f78a9 100644 --- a/src/plugins/HostSkipper.ts +++ b/src/plugins/HostSkipper.ts @@ -104,14 +104,14 @@ export class HostSkipper extends LobbyPlugin { private onParsedStat(player: Player, result: StatResult, isPm: boolean): void { if (!isPm && this.lobby.host === player && this.statIsAfk(result.status) && !this.lobby.isMatching) { - this.logger.trace(`passed afk check ${result.name} -> ${StatStatuses[result.status]}`); + this.logger.trace(`Passed an AFK check ${result.name} -> ${StatStatuses[result.status]}`); if (this.option.afk_check_do_skip) { this.Skip(); } else { if (this.isMapChanged) { - this.lobby.SendMessage('bot : players can start the match by !start vote.'); + this.lobby.SendMessage('bot : Players can start the match by !start vote.'); } else { - this.lobby.SendMessage('bot : players can skip afk host by !skip vote.'); + this.lobby.SendMessage('bot : Players can skip the AFK host by !skip vote.'); } } } @@ -135,22 +135,22 @@ export class HostSkipper extends LobbyPlugin { private vote(player: Player): void { if (this.voting.passed) { - this.logger.debug(`vote from ${player.name} was ignored, already skipped`); + this.logger.debug(`A vote from player ${player.name} was ignored, already skipped.`); } else if (this.elapsedSinceHostChanged < this.option.vote_cooltime_ms) { - this.logger.debug(`vote from ${player.name} was ignored, at cool time.`); + this.logger.debug(`A vote from player ${player.name} was ignored, done during cooltime.`); if (player.isHost) { const secs = (this.option.vote_cooltime_ms - this.elapsedSinceHostChanged) / 1000; - this.lobby.SendMessage(`skip command is in cooltime. you have to wait ${secs.toFixed(2)} sec(s).`); + this.lobby.SendMessage(`The skip command is currently in cooltime. You have to wait ${secs.toFixed(2)} sec(s).`); } } else if (player.isHost) { - this.logger.debug(`host(${player.name}) sent !skip command`); + this.logger.debug(`Host(${player.name}) sent !skip command.`); this.Skip(); } else { if (this.voting.Vote(player)) { - this.logger.trace(`accept skip request from ${player.name}`); + this.logger.trace(`Accepted a skip request from player ${player.name}`); this.checkSkipCount(true); } else { - this.logger.debug(`vote from ${player.name} was ignored, double vote`); + this.logger.debug(`A vote from player ${player.name} was ignored, voted twice.`); } } } @@ -161,13 +161,13 @@ export class HostSkipper extends LobbyPlugin { this.lobby.DeferMessage(`bot : Host skip progress: ${this.voting.toString()}`, 'checkSkipCount', this.option.vote_msg_defer_ms, false); } if (this.voting.passed) { - this.lobby.DeferMessage(`bot : Passed skip vote: ${this.voting.toString()}`, 'checkSkipCount', 100, true); + this.lobby.DeferMessage(`bot : Passed a skip vote: ${this.voting.toString()}`, 'checkSkipCount', 100, true); this.Skip(); } } Skip(): void { - this.logger.info('do skip'); + this.logger.info('Skipping...'); this.StopTimer(); this.SendPluginMessage('skip'); this.timeHostChanged = Date.now(); @@ -175,10 +175,10 @@ export class HostSkipper extends LobbyPlugin { SkipTo(username: string): void { if (!this.lobby.Includes(username)) { - this.logger.info(`invalid username @skipto : ${username}`); + this.logger.info(`Cannot skip to an invalid username : ${username}`); return; } - this.logger.info(`do skipTo : ${username}`); + this.logger.info(`Skipped to : ${username}`); this.StopTimer(); this.SendPluginMessage('skipto', [username]); } @@ -192,19 +192,19 @@ export class HostSkipper extends LobbyPlugin { StartTimer(isFirst: boolean): void { if (this.option.afk_check_interval_ms === 0 || !this.lobby.host || this.lobby.status !== LobbyStatus.Entered || this.lobby.isMatching) return; this.StopTimer(); - this.logger.trace('start afk check timer'); + this.logger.trace('Started the AFK check timer.'); const target = this.lobby.host; this.afkTimer = setTimeout(async () => { if (!this.lobby.isMatching && this.lobby.host === target) { try { const stat1 = await this.lobby.RequestStatAsync(target, true, this.option.afk_check_timeout_ms); - this.logger.trace(`stat check phase 1 ${stat1.name} -> ${StatStatuses[stat1.status]}`); + this.logger.trace(`Stat check phase 1 ${stat1.name} -> ${StatStatuses[stat1.status]}`); if (this.afkTimer !== undefined && this.lobby.host === target && this.statIsAfk(stat1.status)) { // double check and show stat for players await this.lobby.RequestStatAsync(target, false, this.option.afk_check_timeout_ms); } } catch { - this.logger.warn('stat check timeout!'); + this.logger.warn('Stat check timed out!'); } // StopTimerが呼び出されていない、かつホストがターゲットと同じならタイマー再開 if (this.afkTimer !== undefined && this.lobby.host === target) { @@ -216,7 +216,7 @@ export class HostSkipper extends LobbyPlugin { StopTimer(): void { if (this.afkTimer !== undefined) { - this.logger.trace('stop timer'); + this.logger.trace('Stopping timer...'); clearTimeout(this.afkTimer); this.afkTimer = undefined; } @@ -227,6 +227,7 @@ export class HostSkipper extends LobbyPlugin { } GetPluginStatus(): string { - return `-- Host Skipper -- timer : ${this.afkTimer !== undefined ? 'active' : '###'}, skip_vote : ${this.voting.toString()}`; + return `-- Host Skipper -- + Timer : ${this.afkTimer !== undefined ? 'Active' : '###'}, Skip Vote : ${this.voting.toString()}`; } } From d39f8be46de093baa8c16c942c339197cb97c52b Mon Sep 17 00:00:00 2001 From: Xayanide Date: Fri, 27 May 2022 16:17:36 +0800 Subject: [PATCH 2/9] refactor(plugins#HostSkipper): remove inconsistent whitespaces --- src/plugins/HostSkipper.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/plugins/HostSkipper.ts b/src/plugins/HostSkipper.ts index 746f78a9..07ab9e92 100644 --- a/src/plugins/HostSkipper.ts +++ b/src/plugins/HostSkipper.ts @@ -109,9 +109,9 @@ export class HostSkipper extends LobbyPlugin { this.Skip(); } else { if (this.isMapChanged) { - this.lobby.SendMessage('bot : Players can start the match by !start vote.'); + this.lobby.SendMessage('bot: Players can start the match by !start vote.'); } else { - this.lobby.SendMessage('bot : Players can skip the AFK host by !skip vote.'); + this.lobby.SendMessage('bot: Players can skip the AFK host by !skip vote.'); } } } @@ -158,10 +158,10 @@ export class HostSkipper extends LobbyPlugin { // スキップ状況を確認して、必要数に達している場合は private checkSkipCount(showMessage: boolean = false): void { if (this.voting.count !== 0 && showMessage) { - this.lobby.DeferMessage(`bot : Host skip progress: ${this.voting.toString()}`, 'checkSkipCount', this.option.vote_msg_defer_ms, false); + this.lobby.DeferMessage(`bot: Host skip progress: ${this.voting.toString()}`, 'checkSkipCount', this.option.vote_msg_defer_ms, false); } if (this.voting.passed) { - this.lobby.DeferMessage(`bot : Passed a skip vote: ${this.voting.toString()}`, 'checkSkipCount', 100, true); + this.lobby.DeferMessage(`bot: Passed a skip vote: ${this.voting.toString()}`, 'checkSkipCount', 100, true); this.Skip(); } } @@ -175,10 +175,10 @@ export class HostSkipper extends LobbyPlugin { SkipTo(username: string): void { if (!this.lobby.Includes(username)) { - this.logger.info(`Cannot skip to an invalid username : ${username}`); + this.logger.info(`Cannot skip to an invalid username: ${username}`); return; } - this.logger.info(`Skipped to : ${username}`); + this.logger.info(`Skipped to: ${username}`); this.StopTimer(); this.SendPluginMessage('skipto', [username]); } From f5dc193acc8659c1fd3d9b2947515e111fbcdb36 Mon Sep 17 00:00:00 2001 From: Xayanide Date: Fri, 27 May 2022 16:19:09 +0800 Subject: [PATCH 3/9] refactor(plugins#HostSkipper): remove inconsistent whitespaces --- src/plugins/HostSkipper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/HostSkipper.ts b/src/plugins/HostSkipper.ts index 07ab9e92..6f537df7 100644 --- a/src/plugins/HostSkipper.ts +++ b/src/plugins/HostSkipper.ts @@ -228,6 +228,6 @@ export class HostSkipper extends LobbyPlugin { GetPluginStatus(): string { return `-- Host Skipper -- - Timer : ${this.afkTimer !== undefined ? 'Active' : '###'}, Skip Vote : ${this.voting.toString()}`; + Timer: ${this.afkTimer !== undefined ? 'Active' : '###'}, Skip Vote: ${this.voting.toString()}`; } } From d7f24cf2c6d9cdb2f7fc953772a0a9342f847550 Mon Sep 17 00:00:00 2001 From: Xayanide Date: Fri, 27 May 2022 16:19:34 +0800 Subject: [PATCH 4/9] refactor(plugins#HostSkipper): inconsistency --- src/plugins/HostSkipper.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/HostSkipper.ts b/src/plugins/HostSkipper.ts index 6f537df7..4e7c2a37 100644 --- a/src/plugins/HostSkipper.ts +++ b/src/plugins/HostSkipper.ts @@ -228,6 +228,7 @@ export class HostSkipper extends LobbyPlugin { GetPluginStatus(): string { return `-- Host Skipper -- - Timer: ${this.afkTimer !== undefined ? 'Active' : '###'}, Skip Vote: ${this.voting.toString()}`; + Timer: ${this.afkTimer !== undefined ? 'Active' : '###'} + Skip vote: ${this.voting.toString()}`; } } From ec2dc7a024bf97c2c81a0ecc468f73eacc104146 Mon Sep 17 00:00:00 2001 From: Xayanide Date: Fri, 27 May 2022 16:28:44 +0800 Subject: [PATCH 5/9] refactor(plugins#HostSkipper): start using "Bot" instead of "bot" --- src/plugins/HostSkipper.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/HostSkipper.ts b/src/plugins/HostSkipper.ts index 4e7c2a37..7925412b 100644 --- a/src/plugins/HostSkipper.ts +++ b/src/plugins/HostSkipper.ts @@ -109,9 +109,9 @@ export class HostSkipper extends LobbyPlugin { this.Skip(); } else { if (this.isMapChanged) { - this.lobby.SendMessage('bot: Players can start the match by !start vote.'); + this.lobby.SendMessage('Bot: Players can start the match by !start vote.'); } else { - this.lobby.SendMessage('bot: Players can skip the AFK host by !skip vote.'); + this.lobby.SendMessage('Bot: Players can skip the AFK host by !skip vote.'); } } } @@ -158,10 +158,10 @@ export class HostSkipper extends LobbyPlugin { // スキップ状況を確認して、必要数に達している場合は private checkSkipCount(showMessage: boolean = false): void { if (this.voting.count !== 0 && showMessage) { - this.lobby.DeferMessage(`bot: Host skip progress: ${this.voting.toString()}`, 'checkSkipCount', this.option.vote_msg_defer_ms, false); + this.lobby.DeferMessage(`Bot: Host skip progress: ${this.voting.toString()}`, 'checkSkipCount', this.option.vote_msg_defer_ms, false); } if (this.voting.passed) { - this.lobby.DeferMessage(`bot: Passed a skip vote: ${this.voting.toString()}`, 'checkSkipCount', 100, true); + this.lobby.DeferMessage(`Bot: Passed a skip vote: ${this.voting.toString()}`, 'checkSkipCount', 100, true); this.Skip(); } } From abeb4ea4092e1523fccb41bd0537996e6c434169 Mon Sep 17 00:00:00 2001 From: Xayanide Date: Fri, 27 May 2022 18:18:33 +0800 Subject: [PATCH 6/9] refactor(plugins#HostSkipper): inconsistencies --- src/plugins/HostSkipper.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/plugins/HostSkipper.ts b/src/plugins/HostSkipper.ts index 7925412b..bfe249b4 100644 --- a/src/plugins/HostSkipper.ts +++ b/src/plugins/HostSkipper.ts @@ -109,9 +109,9 @@ export class HostSkipper extends LobbyPlugin { this.Skip(); } else { if (this.isMapChanged) { - this.lobby.SendMessage('Bot: Players can start the match by !start vote.'); + this.lobby.SendMessage('Bot: Players can start the match with !start to vote.'); } else { - this.lobby.SendMessage('Bot: Players can skip the AFK host by !skip vote.'); + this.lobby.SendMessage('Bot: Players can skip the AFK host with !skip to vote.'); } } } @@ -135,22 +135,22 @@ export class HostSkipper extends LobbyPlugin { private vote(player: Player): void { if (this.voting.passed) { - this.logger.debug(`A vote from player ${player.name} was ignored, already skipped.`); + this.logger.debug(`A host skip vote from player ${player.name} was ignored, already skipped.`); } else if (this.elapsedSinceHostChanged < this.option.vote_cooltime_ms) { - this.logger.debug(`A vote from player ${player.name} was ignored, done during cooltime.`); + this.logger.debug(`A host skip vote from player ${player.name} was ignored, done during cooltime.`); if (player.isHost) { const secs = (this.option.vote_cooltime_ms - this.elapsedSinceHostChanged) / 1000; - this.lobby.SendMessage(`The skip command is currently in cooltime. You have to wait ${secs.toFixed(2)} sec(s).`); + this.lobby.SendMessage(`The host skip command is currently in cooltime. You have to wait ${secs.toFixed(2)} sec(s).`); } } else if (player.isHost) { - this.logger.debug(`Host(${player.name}) sent !skip command.`); + this.logger.debug(`The host (Player ${player.name}) sent a !skip command.`); this.Skip(); } else { if (this.voting.Vote(player)) { - this.logger.trace(`Accepted a skip request from player ${player.name}`); + this.logger.trace(`Accepted a host skip request from player ${player.name}`); this.checkSkipCount(true); } else { - this.logger.debug(`A vote from player ${player.name} was ignored, voted twice.`); + this.logger.debug(`A host skip vote from player ${player.name} was ignored, voted twice.`); } } } @@ -161,13 +161,13 @@ export class HostSkipper extends LobbyPlugin { this.lobby.DeferMessage(`Bot: Host skip progress: ${this.voting.toString()}`, 'checkSkipCount', this.option.vote_msg_defer_ms, false); } if (this.voting.passed) { - this.lobby.DeferMessage(`Bot: Passed a skip vote: ${this.voting.toString()}`, 'checkSkipCount', 100, true); + this.lobby.DeferMessage(`Bot: Passed a host skip vote: ${this.voting.toString()}`, 'checkSkipCount', 100, true); this.Skip(); } } Skip(): void { - this.logger.info('Skipping...'); + this.logger.info('Skipping host...'); this.StopTimer(); this.SendPluginMessage('skip'); this.timeHostChanged = Date.now(); @@ -175,10 +175,10 @@ export class HostSkipper extends LobbyPlugin { SkipTo(username: string): void { if (!this.lobby.Includes(username)) { - this.logger.info(`Cannot skip to an invalid username: ${username}`); + this.logger.info(`Cannot skip the host to an invalid username: ${username}`); return; } - this.logger.info(`Skipped to: ${username}`); + this.logger.info(`Host has been skipped to: ${username}`); this.StopTimer(); this.SendPluginMessage('skipto', [username]); } @@ -216,7 +216,7 @@ export class HostSkipper extends LobbyPlugin { StopTimer(): void { if (this.afkTimer !== undefined) { - this.logger.trace('Stopping timer...'); + this.logger.trace('Stopping the AFK Kicker timer...'); clearTimeout(this.afkTimer); this.afkTimer = undefined; } From 99da886a99248b01a0dbf2c385a1f5c29f34f68c Mon Sep 17 00:00:00 2001 From: Xayanide Date: Fri, 27 May 2022 18:24:08 +0800 Subject: [PATCH 7/9] refactor(plugins#HostSkipper): it is "Check" not "Kicker" --- src/plugins/HostSkipper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/HostSkipper.ts b/src/plugins/HostSkipper.ts index bfe249b4..bf099d6d 100644 --- a/src/plugins/HostSkipper.ts +++ b/src/plugins/HostSkipper.ts @@ -216,7 +216,7 @@ export class HostSkipper extends LobbyPlugin { StopTimer(): void { if (this.afkTimer !== undefined) { - this.logger.trace('Stopping the AFK Kicker timer...'); + this.logger.trace('Stopping the AFK Check timer...'); clearTimeout(this.afkTimer); this.afkTimer = undefined; } From 52c3fc07700b1293098271bb608ebaaff4c9ae53 Mon Sep 17 00:00:00 2001 From: Xayanide Date: Fri, 27 May 2022 18:25:07 +0800 Subject: [PATCH 8/9] refactor(plugins#HostSkipper): remove redundant "a" --- src/plugins/HostSkipper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/HostSkipper.ts b/src/plugins/HostSkipper.ts index bf099d6d..4fde1cdc 100644 --- a/src/plugins/HostSkipper.ts +++ b/src/plugins/HostSkipper.ts @@ -143,7 +143,7 @@ export class HostSkipper extends LobbyPlugin { this.lobby.SendMessage(`The host skip command is currently in cooltime. You have to wait ${secs.toFixed(2)} sec(s).`); } } else if (player.isHost) { - this.logger.debug(`The host (Player ${player.name}) sent a !skip command.`); + this.logger.debug(`The host (Player ${player.name}) sent !skip command.`); this.Skip(); } else { if (this.voting.Vote(player)) { From 427982f63a490daa320e47352b72f1f382cda683 Mon Sep 17 00:00:00 2001 From: Xayanide Date: Sat, 28 May 2022 15:15:45 +0800 Subject: [PATCH 9/9] refactor(plugins#HostSkipper): missing "the" --- src/plugins/HostSkipper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/HostSkipper.ts b/src/plugins/HostSkipper.ts index 4fde1cdc..35aababa 100644 --- a/src/plugins/HostSkipper.ts +++ b/src/plugins/HostSkipper.ts @@ -178,7 +178,7 @@ export class HostSkipper extends LobbyPlugin { this.logger.info(`Cannot skip the host to an invalid username: ${username}`); return; } - this.logger.info(`Host has been skipped to: ${username}`); + this.logger.info(`The host has been skipped to: ${username}`); this.StopTimer(); this.SendPluginMessage('skipto', [username]); }