From 41bf76ab0d4bc9c60b844018febdbe884e1aa10b Mon Sep 17 00:00:00 2001 From: dakrk Date: Mon, 1 May 2023 15:03:14 +0100 Subject: [PATCH] Configurable chat history length The previous default of 5 messages is utterly lame and didn't provide enough context to anything, and was also a downgrade from the old server as that had 10 messages by default (of which we're now going back to with this change). --- config.example.toml | 1 + src/IConfig.ts | 1 + src/WSServer.ts | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config.example.toml b/config.example.toml index 90ceb59..5c6c635 100644 --- a/config.example.toml +++ b/config.example.toml @@ -27,6 +27,7 @@ bancmd = "iptables -A INPUT -s $IP -j REJECT" moderatorEnabled = true usernameblacklist = [] maxChatLength = 100 +maxChatHistoryLength = 10 # Temporarily mute a user if they send more than x messages in n seconds automute = {enabled = true, seconds = 5, messages = 5} # How long a temporary mute lasts, in seconds diff --git a/src/IConfig.ts b/src/IConfig.ts index 9d0f81e..ab8ec6e 100644 --- a/src/IConfig.ts +++ b/src/IConfig.ts @@ -21,6 +21,7 @@ export default interface IConfig { moderatorEnabled : boolean; usernameblacklist : string[]; maxChatLength : number; + maxChatHistoryLength : number; automute : { enabled: boolean; seconds: number; diff --git a/src/WSServer.ts b/src/WSServer.ts index f53fd33..188ed27 100644 --- a/src/WSServer.ts +++ b/src/WSServer.ts @@ -47,13 +47,13 @@ export default class WSServer { private ModPerms : number; private VM : VM; constructor(config : IConfig, vm : VM) { - this.ChatHistory = new CircularBuffer<{user:string,msg:string}>(Array, 5); + this.Config = config; + this.ChatHistory = new CircularBuffer<{user:string,msg:string}>(Array, this.Config.collabvm.maxChatHistoryLength); this.TurnQueue = new Queue(); this.TurnTime = 0; this.TurnIntervalRunning = false; this.clients = []; this.ips = []; - this.Config = config; this.voteInProgress = false; this.voteTime = 0; this.voteCooldown = 0;