Improved compatibility with chat_anticurse, chat_antiflood and may-be other chat mods

This commit is contained in:
AndrejIT 2017-06-04 02:02:55 +03:00
parent f9841a938e
commit 9dab1fa9ad
6 changed files with 30 additions and 44 deletions

0
LICENSE Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

1
depends.txt Normal file → Executable file
View File

@ -1 +1,2 @@
chat_anticurse?
chat_antiflood?

0
description.txt Normal file → Executable file
View File

27
init.lua Normal file → Executable file
View File

@ -166,15 +166,6 @@ minetest.register_on_chat_message(function(name, message)
return
end
if chat_anticurse then
local uncensored = chat_anticurse.check_message(name, message)
if uncensored == 2 or uncensored > 2 then
return true
elseif uncensored == 1 then
return
end
end
submes = string.match(message, "^/(.+)")
if submes then
return
@ -243,27 +234,21 @@ if minetest.chatcommands["msg"] then
local old_command = minetest.chatcommands["msg"].func
minetest.chatcommands["msg"].func = function(name, param)
local sendto, message = param:match("^(%S+)%s(.+)$")
-- Check if old /msg was succeful
local result, msg = old_command(name, param)
if sendto and message and chat2.users[sendto] then
if chat_anticurse then
local uncensored = chat_anticurse.check_message(name, message)
if uncensored == 2 or uncensored > 2 then
return old_command(name, param)
elseif uncensored == 1 then
return old_command(name, param)
end
end
local player = minetest.get_player_by_name(sendto)
local sender = minetest.get_player_by_name(name)
if player and sender then
if result and player and sender then
chat2.send_message(player, string.format("<%s> %s", name, message), 0xFF00FF)
chat2.send_message(sender, string.format("<%s> %s", name, message), 0xF000F0)
minetest.log("action", "chat2 msg:"..string.format("<%s> %s", name, message))
end
end
return old_command(name, param)
return result, msg
end
end

0
mod.conf Normal file → Executable file
View File