Skip to content
This repository was archived by the owner on Jul 17, 2025. It is now read-only.

Commit d930680

Browse files
authored
Merge pull request #45 from DreamWeave-MP/feat/chat-color-police
feat(server): Implement chat color filtering for player submitted messages
2 parents 38b4fc3 + 7e3c002 commit d930680

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

scripts/config.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ config.shareVideos = true
118118
-- Whether mobs and npcs in the game should be shared for all players when killed
119119
config.shareKills = true
120120

121+
-- Enabling this option filters chat colors to prevent custom colored messages.
122+
-- When enabled, '#' in a message is escaped as '##'.
123+
config.filterChatColors = true
124+
121125
-- Which clientside script records should be blanked out so they are not run
122126
-- Note: By default, the original character generation scripts are included
123127
-- because they're not suitable for multiplayer

scripts/eventHandler.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,10 @@ eventHandler.OnPlayerSendMessage = function(pid, message)
826826
if Players[pid] ~= nil and Players[pid]:IsLoggedIn() then
827827
dreamweave.LogMessage(enumerations.log.INFO, logicHandler.GetChatName(pid) .. ": " .. message)
828828

829+
if config.filterChatColors then
830+
message = message:gsub("#", "##")
831+
end
832+
829833
local eventStatus = customEventHooks.triggerValidators("OnPlayerSendMessage", {pid, message})
830834

831835
if eventStatus.validDefaultHandler then

0 commit comments

Comments
 (0)