Skip to content

Commit

Permalink
ctf_chat: Prevent /msg from bypassing filter (#1045)
Browse files Browse the repository at this point in the history
Manually run `filter.check_message`, and `filter.on_violation` if the former returns false.
  • Loading branch information
magnetar47 authored Aug 17, 2022
1 parent a21d01d commit 24f083e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ globals = {
"dropondie", "grenades",

"chatcmdbuilder", "crafting", "hpbar", "playertag", "random_messages",
"skybox", "throwable_snow", "worldedit",
"skybox", "throwable_snow", "worldedit", "filter",

"default", "doors", "player_api", "sfinv", "binoculars",

Expand Down
6 changes: 6 additions & 0 deletions mods/ctf/ctf_chat/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ minetest.override_chatcommand("msg", {
return false, "The player " .. sendto .. " is not online."
end

-- Run the message through filter if it exists
if filter and not filter.check_message(name, message) then
filter.on_violation(name, message)
return false
end

-- Message color
local color = minetest.settings:get("ctf_chat.message_color") or "#E043FF"
local pteam = ctf_teams.get(name)
Expand Down
1 change: 1 addition & 0 deletions mods/ctf/ctf_chat/mod.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
name = ctf_chat
depends = ctf_teams
optional_depends = filter

0 comments on commit 24f083e

Please sign in to comment.