From ef790c705ad8478a0d743495bddf906c23f678a6 Mon Sep 17 00:00:00 2001
From: Linventif <linventif@gmail.com>
Date: Sun, 24 Sep 2023 09:58:27 +0200
Subject: [PATCH] remove trigger on sync chat and add prefix

---
 lua/gmod_integration/server/sv_main.lua | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lua/gmod_integration/server/sv_main.lua b/lua/gmod_integration/server/sv_main.lua
index 6e6e940..1d3c136 100644
--- a/lua/gmod_integration/server/sv_main.lua
+++ b/lua/gmod_integration/server/sv_main.lua
@@ -52,7 +52,11 @@ end
 
 local function triggerChat(text)
     for k, v in pairs(gmInte.config.chatTrigger) do
-        if (string.StartWith(text, k)) then return true end
+        if (string.StartWith(text, k)) then
+            if (tostring(v) == "false") then return false end
+            if (tostring(v) == "true") then v = "" end
+            return v .. string.sub(text, string.len(k) + 1)
+        end
     end
 
     return false
@@ -60,12 +64,13 @@ end
 
 function gmInte.playerSay(ply, text, team)
     if (!gmInte.config.syncChat) then return end
-    if (!triggerChat(text) && !gmInte.config.chatTriggerAll) then return end
+    local triggerText = triggerChat(text)
+    if (!triggerText && !gmInte.config.chatTriggerAll) then return end
 
     gmInte.post("/server/user/say",
         {
             ["steamID64"] = ply:SteamID64(),
-            ["message"] = text,
+            ["message"] = triggerText,
             ["name"] = ply:Nick(),
             ["team"] = team,
         }