forked from ThomasMonroe314/ugxrealms
add chatdam mod, [server_essensials] update
This commit is contained in:
parent
e938655e02
commit
f8c4319bb9
@ -37,15 +37,16 @@ give_initial_stuff = true
|
||||
disable_fire = true
|
||||
playereffects_autosave = 60
|
||||
enable_sprinting = true
|
||||
static_spawnpoint = -2770,25,2327
|
||||
static_spawnpoint = 16390,28,20401
|
||||
enable_tnt = false
|
||||
protector_hurt = 0
|
||||
protector_flip = true
|
||||
protector_spawn = 10
|
||||
protector_pvp = true
|
||||
name_restrictions.pronounceability = # nil=disalbed
|
||||
name_restrictions.pronounceability = # nil=disalbed, 0=everything blocked, .5=strict, 1=normal, 2=relaxed
|
||||
day_time_ratio = 75
|
||||
night_time_ratio = 25
|
||||
maximum_characters_per_message = 300
|
||||
#
|
||||
#################IRC################
|
||||
#
|
||||
|
60
worldmods/chatdam/init.lua
Normal file
60
worldmods/chatdam/init.lua
Normal file
@ -0,0 +1,60 @@
|
||||
--[[
|
||||
-- That Dam Chat
|
||||
-- Wait, it's a Chat Dam
|
||||
-- Anyway, the pun failed
|
||||
--
|
||||
-- License : WTFPL
|
||||
-- ßÿ Lymkwi/LeMagnesium/Mg
|
||||
--
|
||||
--]]
|
||||
|
||||
chatdam = {}
|
||||
|
||||
chatdam.data = {}
|
||||
|
||||
-- Retrieve some config stuff
|
||||
chatdam.conf = {}
|
||||
chatdam.conf.MAXIMUM_CHARACTERS_PER_MESSAGE = tonumber(minetest.setting_get("maximum_characters_per_message") or "255")
|
||||
chatdam.conf.MAXIMUM_MESSAGES_PER_INTERVAL = tonumber(minetest.setting_get("maximum_messages_per_interval") or "3")
|
||||
chatdam.conf.FLOOD_INTERVAL = tonumber(minetest.setting_get("flood_interval") or "2")
|
||||
|
||||
-- Main control function. A real nightmare for flooders.
|
||||
function chatdam.floodcontrol(name, message)
|
||||
local violation
|
||||
|
||||
-- Kick for message length
|
||||
if message:len() > chatdam.conf.MAXIMUM_CHARACTERS_PER_MESSAGE then
|
||||
violation = ("Your sent a message with more characters\nthan allowed (%s maximum)"):format(chatdam.conf.MAXIMUM_CHARACTERS_PER_MESSAGE)
|
||||
end
|
||||
|
||||
-- Kick for message frequency
|
||||
local rightnow = tonumber(os.date("%s"))
|
||||
-- By the power of maths I check the last <interval> seconds
|
||||
if rightnow > chatdam.data[name].lastmsg+chatdam.conf.FLOOD_INTERVAL then
|
||||
chatdam.data[name].msgs = 1
|
||||
chatdam.data[name].lastmsg = rightnow
|
||||
else
|
||||
chatdam.data[name].msgs = chatdam.data[name].msgs + 1
|
||||
if chatdam.data[name].msgs > chatdam.conf.MAXIMUM_MESSAGES_PER_INTERVAL then
|
||||
violation = ("You sent too many messages in a short\namount of time (maximum allowed is %s for %s seconds)"):format(chatdam.conf.MAXIMUM_MESSAGES_PER_INTERVAL, chatdam.conf.FLOOD_INTERVAL)
|
||||
end
|
||||
end
|
||||
|
||||
if violation then
|
||||
minetest.kick_player(name, violation)
|
||||
return true -- Cancel anything that might happen after, and the engine's response, which is to send the message
|
||||
end
|
||||
end
|
||||
minetest.register_on_chat_message(chatdam.floodcontrol)
|
||||
|
||||
-- We create tracking data for the players' messages here...
|
||||
minetest.register_on_joinplayer(function(pref)
|
||||
chatdam.data[pref:get_player_name()] = {lastmsg=0, msgs=0}
|
||||
end)
|
||||
|
||||
-- ... and we discard it here
|
||||
minetest.register_on_leaveplayer(function(pref)
|
||||
chatdam.data[pref:get_player_name()] = nil
|
||||
end)
|
||||
|
||||
minetest.log("[ChatDam] Loaded")
|
19
worldmods/chatdam/readme.md
Normal file
19
worldmods/chatdam/readme.md
Normal file
@ -0,0 +1,19 @@
|
||||
## [chatdam]
|
||||
### A mod to control chat spam and flooding.
|
||||
--
|
||||
-- That Dam Chat
|
||||
-- Wait, it's a Chat Dam
|
||||
-- Anyway, the pun failed
|
||||
--
|
||||
-- License : WTFPL
|
||||
-- ßÿ Lymkwi/LeMagnesium/Mg
|
||||
--
|
||||
|
||||
#### minetest.conf settings:
|
||||
|
||||
-- Spam control
|
||||
maximum_characters_per_message = 255 -- Max allowed characters in a single chat message.
|
||||
|
||||
-- Flood control
|
||||
flood_interval = 2 -- Interval in seconds that is checked for flooding.
|
||||
maximum_messages_per_interval = 3 -- Max allowed chat messages per interval.
|
@ -316,7 +316,9 @@ minetest.register_on_newplayer(function(player)
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_chat_message(function(name, message)
|
||||
|
||||
-- Disabled, this is handled by [chatdam] mod.
|
||||
--[[minetest.register_on_chat_message(function(name, message)
|
||||
if KICK_CHATSPAM and not minetest.check_player_privs(name, {chatspam=true}) and
|
||||
string.len(message) > MAX_CHAT_MSG_LENGTH then
|
||||
minetest.kick_player(name,
|
||||
@ -327,6 +329,7 @@ minetest.register_on_chat_message(function(name, message)
|
||||
end
|
||||
return
|
||||
end)
|
||||
--]]
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
-- Loop through all connected players
|
||||
|
@ -15,9 +15,12 @@ FIRST_TIME_JOIN_MSG = " has joined the server for the first time, Welcome!"
|
||||
-- All messages sent with the /broadcast command will be prefixed with this
|
||||
BROADCAST_PREFIX = "[SERVER]"
|
||||
|
||||
-- Disabled, this is handled by [chatdam] mod.
|
||||
--[[
|
||||
-- If true, players who send a chat message longer than MAX_CHAT_MSG_LENGTH will be kicked
|
||||
KICK_CHATSPAM = true
|
||||
MAX_CHAT_MSG_LENGTH = 300
|
||||
--]]
|
||||
|
||||
-- Delay in seconds that will occur between issuing /spawn command and actually being teleported to the static_spawnpoint
|
||||
SPAWN_DELAY = 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user