From f1ea2a1b64c82326edba2ee037a8102c89feccf6 Mon Sep 17 00:00:00 2001 From: alexbcberio Date: Thu, 6 Jan 2022 00:44:01 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20prefix=20and=20prevent=20exce?= =?UTF-8?q?eding=20message=20length?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/chatClient/clientActions/say/index.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/backend/chatClient/clientActions/say/index.ts b/src/backend/chatClient/clientActions/say/index.ts index 89d7626..8d04801 100644 --- a/src/backend/chatClient/clientActions/say/index.ts +++ b/src/backend/chatClient/clientActions/say/index.ts @@ -1,7 +1,18 @@ import { chatClient } from "../.."; -// send a chat message +const maxMessageLength = 500; + async function say(channel: string, message: string): Promise { + message = `MrDestructoid ${message}`; + + if (message.length > 500) { + const suffix = "..."; + message = `${message.substring( + 0, + maxMessageLength - suffix.length + )}${suffix}`; + } + await chatClient.say(channel, message); }