Cleanup control characters from messages
This commit is contained in:
parent
bcf6179808
commit
590bfde2bc
4
cleaner.lua
Normal file
4
cleaner.lua
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
beerchat.register_callback('on_receive', function(msg_data)
|
||||
msg_data.message = msg_data.message:gsub('%c','')
|
||||
end)
|
7
hash.lua
7
hash.lua
@ -4,6 +4,13 @@
|
||||
hashchat_lastrecv = {}
|
||||
|
||||
minetest.register_on_chat_message(function(name, message)
|
||||
local msg_data = {name=name,message=message}
|
||||
if beerchat.execute_callbacks('on_receive', msg_data) then
|
||||
message = msg_data.message
|
||||
else
|
||||
return false
|
||||
end
|
||||
|
||||
local channel_name, msg = string.match(message, "^#(.-): (.*)")
|
||||
if not beerchat.channels[channel_name] then
|
||||
channel_name, msg = string.match(message, "^#(.-) (.*)")
|
||||
|
@ -13,6 +13,9 @@ beerchat.cb.before_mute = {} -- executed before player is muted
|
||||
beerchat.cb.before_check_muted = {} -- executed before has_player_muted_player checks
|
||||
beerchat.cb.on_forced_join = {} -- executed right after player is forced to channel
|
||||
|
||||
-- Callbacks that can edit message contents
|
||||
beerchat.cb.on_receive = {} -- executed when new message is received
|
||||
|
||||
beerchat.register_callback = function(trigger, fn)
|
||||
if type(fn) ~= 'function' then
|
||||
print('Error: Invalid fn argument for beerchat.register_callback, must be function. Got ' .. type(fn))
|
||||
|
4
init.lua
4
init.lua
@ -79,6 +79,10 @@ if minetest.settings:get_bool("beerchat.enable_jail") then
|
||||
dofile(MP.."/jail.lua")
|
||||
end
|
||||
|
||||
if minetest.settings:get_bool("beerchat.enable_cleaner") then
|
||||
dofile(MP.."/cleaner.lua")
|
||||
end
|
||||
|
||||
if minetest.settings:get_bool("enable_beerchat_integration_test") then
|
||||
dofile(MP.."/integration_test.lua")
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user