Skip to content

Commit

Permalink
Improved censor (refs #87)
Browse files Browse the repository at this point in the history
* can now correctly be disabled
* made some extra punishments available
  • Loading branch information
timosmit committed Feb 7, 2019
1 parent 0386ed2 commit 8c0797f
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 9 deletions.
6 changes: 5 additions & 1 deletion config/wolfadmin.toml
Expand Up @@ -40,8 +40,12 @@ interval = 30

[censor]
file = "censor.toml"
mode = 1
enabled = 1
mute = 60
burn = 1
slap = 0
kill = 0
gib = 0
kick = 1

[game]
Expand Down
32 changes: 28 additions & 4 deletions luascripts/wolfadmin/admin/censor.lua
Expand Up @@ -15,12 +15,12 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.

local auth = wolfa_requireModule("auth.auth")

local admin = wolfa_requireModule("admin.admin")
local mutes = wolfa_requireModule("admin.mutes")
local history = wolfa_requireModule("admin.history")

local auth = wolfa_requireModule("auth.auth")

local players = wolfa_requireModule("players.players")

local events = wolfa_requireModule("util.events")
Expand Down Expand Up @@ -56,6 +56,30 @@ function censor.filterMessage(...)
end

function censor.punishClient(clientId)
if settings.get("g_censorBurn") ~= 0 then
admin.burnPlayer(clientId)

et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dburn: ^7"..players.getName(clientId).." ^9burnt his tongue.\";")
end

if settings.get("g_censorSlap") ~= 0 then
admin.slapPlayer(clientId, 20)

et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dslap: ^7"..players.getName(clientId).." ^9was slapped for his foul language.\";")
end

if settings.get("g_censorKill") ~= 0 and settings.get("g_censorGib") == 0 then
admin.killPlayer(clientId)

et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dkill: ^7"..players.getName(clientId).." ^9stumbled over his words.\";")
end

if settings.get("g_censorGib") ~= 0 then
admin.gibPlayer(clientId)

et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat -1 \"^dgib: ^7"..players.getName(clientId).." ^9should not have said that.\";")
end

if settings.get("g_censorMute") > 0 then
mutes.add(clientId, -1337, players.MUTE_CHAT + players.MUTE_VOICE, settings.get("g_censorMute"), "censor")

Expand Down Expand Up @@ -114,7 +138,7 @@ function censor.clear()
end

function censor.onClientConnectAttempt(clientId, firstTime, isBot)
if auth.isPlayerAllowed(clientId, auth.PERM_NOCENSOR) then
if settings.get("g_censor") == 0 or auth.isPlayerAllowed(clientId, auth.PERM_NOCENSOR) then
return
end

Expand All @@ -136,7 +160,7 @@ function censor.onClientConnectAttempt(clientId, firstTime, isBot)
end

function censor.onClientNameChange(clientId, oldName, newName)
if auth.isPlayerAllowed(clientId, auth.PERM_NOCENSOR) then
if settings.get("g_censor") == 0 or auth.isPlayerAllowed(clientId, auth.PERM_NOCENSOR) then
return
end

Expand Down
4 changes: 2 additions & 2 deletions luascripts/wolfadmin/commands/client/say.lua
Expand Up @@ -44,10 +44,10 @@ function commandSay(clientId, command, ...)
return true
end

if not auth.isPlayerAllowed(clientId, auth.PERM_NOCENSOR) then
if settings.get("g_censor") ~= 0 and not auth.isPlayerAllowed(clientId, auth.PERM_NOCENSOR) then
local censored, message = censor.filterMessage(...)

if censored and settings.get("g_censorMode") ~= 0 then
if censored then
censor.punishClient(clientId)

et.G_Say(clientId, util.getChatFromCommand(command), message)
Expand Down
12 changes: 10 additions & 2 deletions luascripts/wolfadmin/util/settings.lua
Expand Up @@ -30,8 +30,12 @@ local data = {
["g_fileCombis"] = "combis.toml",
["g_fileSprees"] = "sprees.toml",
["g_playerHistory"] = 1,
["g_censorMode"] = 1,
["g_censor"] = 1,
["g_censorMute"] = 60,
["g_censorBurn"] = 1,
["g_censorSlap"] = 0,
["g_censorKill"] = 0,
["g_censorGib"] = 0,
["g_censorKick"] = 1,
["g_combiMessages"] = 3,
["g_combiSounds"] = 3,
Expand Down Expand Up @@ -101,8 +105,12 @@ local cfgStructure = {
},
["censor"] = {
["file"] = "g_fileCensor",
["mode"] = "g_censorMode",
["enabled"] = "g_censor",
["mute"] = "g_censorMute",
["burn"] = "g_censorBurn",
["slap"] = "g_censorSlap",
["kill"] = "g_censorKill",
["gib"] = "g_censorGib",
["kick"] = "g_censorKick"
},
["game"] = {
Expand Down

0 comments on commit 8c0797f

Please sign in to comment.