hignore: add settings and logging
This commit is contained in:
parent
ceefc428b1
commit
66c450a279
@ -1,5 +1,25 @@
|
|||||||
-- CC0/Unlicense system32 2020
|
-- CC0/Unlicense system32 2020
|
||||||
|
|
||||||
|
local function init_settings(setting_table)
|
||||||
|
for k, v in pairs(setting_table) do
|
||||||
|
if minetest.settings:get(k) == nil then
|
||||||
|
if type(v) == "boolean" then
|
||||||
|
minetest.settings:set_bool(k, v)
|
||||||
|
else
|
||||||
|
minetest.settings:set(k, v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
init_settings({
|
||||||
|
hignore_ignore_all = false,
|
||||||
|
hignore_highlight_all = false,
|
||||||
|
hignore_highlight_all_color = "#FFFFFF",
|
||||||
|
hignore_strip_all = false,
|
||||||
|
hignore_log = true
|
||||||
|
})
|
||||||
|
|
||||||
local storage = minetest.get_mod_storage()
|
local storage = minetest.get_mod_storage()
|
||||||
|
|
||||||
local function storage_init_table(key)
|
local function storage_init_table(key)
|
||||||
@ -46,6 +66,17 @@ local function localize_player(player)
|
|||||||
return player .. "@" .. name .. ":" .. info.port
|
return player .. "@" .. name .. ":" .. info.port
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local playerat
|
||||||
|
|
||||||
|
local function log(message)
|
||||||
|
if minetest.settings:get_bool("hignore_log") then
|
||||||
|
if playerat == nil then
|
||||||
|
playerat = localize_player(minetest.localplayer:get_name())
|
||||||
|
end
|
||||||
|
minetest.log("action", "[hignore] " .. playerat .. " " .. message)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- TODO: log messages
|
-- TODO: log messages
|
||||||
minetest.register_on_receiving_chat_message(function(message)
|
minetest.register_on_receiving_chat_message(function(message)
|
||||||
local dm = message:match(".*rom (.*): .*")
|
local dm = message:match(".*rom (.*): .*")
|
||||||
@ -64,7 +95,8 @@ minetest.register_on_receiving_chat_message(function(message)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- ignore and hide
|
-- ignore and hide
|
||||||
if hignore.ignore[player] then
|
if hignore.ignore[player] or minetest.settings:get_bool("hignore_ignore_all") then
|
||||||
|
log(message)
|
||||||
if hignore.ignore[player] == "summarize" then
|
if hignore.ignore[player] == "summarize" then
|
||||||
if dm then
|
if dm then
|
||||||
minetest.display_chat_message(player .. " sent you a DM.")
|
minetest.display_chat_message(player .. " sent you a DM.")
|
||||||
@ -76,7 +108,7 @@ minetest.register_on_receiving_chat_message(function(message)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- strip title
|
-- strip title
|
||||||
if not is_dm and hignore.strip[player] then
|
if not is_dm and (hignore.strip[player] or minetest.settings:get_bool("hignore_strip_all")) then
|
||||||
message = message:match(".- | (.*)")
|
message = message:match(".- | (.*)")
|
||||||
if hignore.highlight[player] == nil then
|
if hignore.highlight[player] == nil then
|
||||||
minetest.display_chat_message(message)
|
minetest.display_chat_message(message)
|
||||||
@ -89,6 +121,14 @@ minetest.register_on_receiving_chat_message(function(message)
|
|||||||
minetest.display_chat_message(minetest.colorize(hignore.highlight[player], message))
|
minetest.display_chat_message(minetest.colorize(hignore.highlight[player], message))
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if minetest.settings:get_bool("hignore_highlight_all") then
|
||||||
|
minetest.display_chat_message(
|
||||||
|
minetest.colorize(
|
||||||
|
minetest.settings:get("hignore_highlight_all_color"),
|
||||||
|
message))
|
||||||
|
return true
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
5
clientmods/hignore/settingtypes.txt
Normal file
5
clientmods/hignore/settingtypes.txt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
hignore_log (Log highlighted/ignored/stripped messages) bool true
|
||||||
|
hignore_strip_all (Strip titles of all players) bool false
|
||||||
|
hignore_highlight_all (Highlight all player messages) bool false
|
||||||
|
hignore_highlight_all_color (Color to highlight all player messages) string "#FFFFFF"
|
||||||
|
hignore_ignore_all (Ignore all player messages) bool false
|
Loading…
x
Reference in New Issue
Block a user