I would also like to edit the /ban and /shutdown commands to be more extensive and include several options. I could just create a new command, but it would be far more convenient to intercept the commands and then run the needed function as I don't need to change any privileges, and can do that through the function anyway.
My basic filter function looks like this:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
-- if warnable word is used
for i, word in ipairs(WARNABLE) do
minetest.register_on_chat_message(function(name, message)
local msg = message:lower()
-- ignore commands
if message:sub(1, 1) ~= "/" then
-- filter for word(s)
if msg:find(word.warn) ~= nil then
-- warn player
minetest.chat_send_player(name, 'Please do not use emotional words, including "'..word.warn..'," in the chat.')
return true -- prevent message from showing in chat
end
end
end)
end
I also have two other tables and for loops to register words that kick or ban the player (with xban2) using the same basic method.
Thanks!