mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-02-21 19:20:07 +02:00
Report script kicks and bans to moderation-log channel.
This commit is contained in:
parent
9de94d38a9
commit
26b84037b1
@ -239,10 +239,8 @@ local function on_capsule_used(event)
|
||||
else
|
||||
players_warned[event.player_index] = true
|
||||
if nuke_control.enable_autokick then
|
||||
game.kick_player(
|
||||
player,
|
||||
format('Damaged entities: %s with %s -Antigrief', list_damaged_entities(item_name, entities), item_name)
|
||||
)
|
||||
local reason = format('Damaged entities: %s with %s -Antigrief', list_damaged_entities(item_name, entities), item_name)
|
||||
Report.kick_player(player, reason)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -299,7 +297,8 @@ local function on_entity_died(event)
|
||||
train.manual_mode = false
|
||||
Task.set_timeout_in_ticks(30, train_to_manual, train)
|
||||
if players_warned[player.index] and num_passengers == 1 then -- jail for later offenses if they're solely guilty
|
||||
Report.jail(player)
|
||||
Report.jail(player, '<script>')
|
||||
Report.report(nil, player, player.name .. ' used a train to destroy another train and has been jailed.')
|
||||
Utils.print_admins({'nuke_control.train_jailing', player.name})
|
||||
else -- warn for first offense or if there's someone else in the train
|
||||
players_warned[player.index] = true
|
||||
|
@ -250,13 +250,13 @@ end
|
||||
|
||||
--- Places a target in jail
|
||||
-- @param target_player <LuaPlayer> the target to jail
|
||||
-- @param player <LuaPlayer|nil> the admin as LuaPlayer or server as nil
|
||||
-- @param player <LuaPlayer|'<script>'|nil> the admin as LuaPlayer or '<script>' or server as nil
|
||||
function Module.jail(target_player, player)
|
||||
local print
|
||||
if player then
|
||||
if type(player) == 'table' then
|
||||
print = player.print
|
||||
else
|
||||
player = {name = 'server'}
|
||||
player = {name = player or '<server>'}
|
||||
print = log
|
||||
end
|
||||
|
||||
@ -470,6 +470,50 @@ function Module.ban_player(player, reason)
|
||||
|
||||
text = table.concat(text)
|
||||
Server.to_discord_named_embed_raw(moderation_log_channel, text)
|
||||
Server.to_discord_named_raw(moderation_log_channel, moderator_role_mention)
|
||||
end
|
||||
|
||||
--- kicks the player and reports the kick to moderation log channel.
|
||||
-- @param player<LuaPlayer>
|
||||
-- @param reason<string?> defaults to empty string.
|
||||
function Module.kick_player(player, reason)
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if reason == nil then
|
||||
reason = ''
|
||||
elseif type(reason) ~= 'string' then
|
||||
error('reason must be a string or nil', 2)
|
||||
end
|
||||
|
||||
game.kick_player(player, reason)
|
||||
|
||||
local server_id = Server.get_server_id()
|
||||
local server_name = Server.get_server_name()
|
||||
|
||||
local text = {'**'}
|
||||
text[#text + 1] = Utils.sanitise_string_for_discord(player.name)
|
||||
text[#text + 1] = ' was kicked by <script>**\\n'
|
||||
|
||||
if server_id ~= '' then
|
||||
text[#text + 1] = 'Server: s'
|
||||
text[#text + 1] = Utils.sanitise_string_for_discord(server_id)
|
||||
text[#text + 1] = ' - '
|
||||
text[#text + 1] = Utils.sanitise_string_for_discord(server_name)
|
||||
text[#text + 1] = '\\n'
|
||||
end
|
||||
|
||||
text[#text + 1] = ' Game time: '
|
||||
text[#text + 1] = Utils.format_time(game.tick)
|
||||
text[#text + 1] = '\\nPlayer online time: '
|
||||
text[#text + 1] = Utils.format_time(player.online_time)
|
||||
text[#text + 1] = '\\nReason: '
|
||||
text[#text + 1] = Utils.sanitise_string_for_discord(reason)
|
||||
|
||||
text = table.concat(text)
|
||||
Server.to_discord_named_embed_raw(moderation_log_channel, text)
|
||||
Server.to_discord_named_raw(moderation_log_channel, moderator_role_mention)
|
||||
end
|
||||
|
||||
Gui.on_custom_close(report_frame_name, function(event)
|
||||
|
@ -289,13 +289,13 @@ Please be careful!
|
||||
end
|
||||
|
||||
if number_of_spilled >= anti_grief_tries then
|
||||
Report.jail(player, nil)
|
||||
Report.jail(player, '<script>')
|
||||
player.print({'', '[color=yellow]', {'concrete_jungle.anti_grief_jail_reason'}, '[/color]'})
|
||||
Report.report(nil, player, 'Spilling too many items on the ground')
|
||||
times_spilled[player.index] = nil
|
||||
return
|
||||
elseif number_of_spilled == anti_grief_kick_tries then
|
||||
game.kick_player(player, {'concrete_jungle.anti_grief_kick_reason'})
|
||||
Report.kick_player(player, 'Spilling too many items on the ground')
|
||||
end
|
||||
times_spilled[player.index] = {count = number_of_spilled + 1, tick = game.tick}
|
||||
end
|
||||
|
@ -46,7 +46,7 @@ Event.add(CaveCollapse.events.on_collapse, function(event)
|
||||
player_collapses[player_index] = count
|
||||
local player = game.get_player(player_index)
|
||||
if global_primitives.autojail and count > allowed_collapses_first_hour and player.online_time < 216000 and not jailed_players[player_index] then
|
||||
Report.jail(player)
|
||||
Report.jail(player, '<script>')
|
||||
Report.report(nil, player, format('Caused %d collapses in the first hour', count))
|
||||
jailed_players[player_index] = true
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user