130 lines
3.4 KiB
Lua
Raw Normal View History

2020-04-22 22:31:17 +05:30
-- Restrict private messaging to players with a score of 500+
local function canPM(name)
2021-11-28 21:00:27 +01:00
return true
-- return minetest.check_player_privs(name, {kick=true}) or ctf_stats.player(name).score > 500
2020-04-22 22:31:17 +05:30
end
local old = minetest.registered_chatcommands["msg"].func
minetest.override_chatcommand("msg", {
func = function(name, params)
if canPM(name) then
return old(name, params)
else
return false, "You need at least 500 score to private message!"
end
end
})
local oldmail = minetest.registered_chatcommands["mail"].func
minetest.override_chatcommand("mail", {
func = function(name, params)
if canPM(name) then
return oldmail(name, params)
else
return false, "You need at least 500 score to private message!"
end
end
})
minetest.override_chatcommand("admin", {
func = function()
-- lol
2021-11-28 21:00:27 +01:00
return true, "Admins are Lone_Wolf and savilli. Please use /report for any issues."
2020-04-22 22:31:17 +05:30
end
})
-- Disable IRC bot-command /whereis
if irc then
irc.bot_commands["whereis"] = nil
end
-- on_violation callback for the filter mod
-- Decreases player health by 6 HP upon every violation
if filter then
filter.register_on_violation(function(name)
local player = minetest.get_player_by_name(name)
if player then
local hp = player:get_hp()
if hp > 3*2 then
hp = hp - 3*2
else
hp = 1
end
player:set_hp(hp)
end
end)
end
--
--
--- Staff Channel
--- Moved here because http api can't be requested unless in the main file
--
--
local staff = {}
local http = minetest.request_http_api()
2021-11-28 21:00:27 +01:00
local function grab_staff_messages()
http.fetch({
url = "localhost:31337",
timeout = 5,
method = "GET",
}, function(res)
if res.data == "" then return end
local messages = minetest.parse_json(res.data)
if messages and type(messages) == "table" and #messages > 0 then
minetest.log("action", "[server_chat]: Sending messages sent from Discord: " .. dump(messages))
for toname in pairs(staff) do
for _, msg in pairs(messages) do
minetest.chat_send_player(toname, minetest.colorize("#ffcc00", "[STAFF] " .. msg))
end
end
end
end)
minetest.after(5, grab_staff_messages)
end
2021-03-06 16:36:32 +01:00
-- Grabs messages from CTF bot's !x <message>
if http and minetest.settings:get("server_chat_relay_from_discord") then
2021-11-28 21:00:27 +01:00
minetest.after(5, grab_staff_messages)
end
2021-11-28 21:00:27 +01:00
local function send_staff_message(msg, prefix, discord_prefix, discord_webhook)
minetest.log("action", string.format("[server_chat] " .. prefix .. msg))
for toname in pairs(ctf_report.staff) do
minetest.chat_send_player(toname, minetest.colorize("#ffcc00", prefix .. msg))
end
2021-11-28 21:00:27 +01:00
-- Send to discord
if http and minetest.settings:get(discord_webhook) then
http.fetch({
2021-11-28 21:00:27 +01:00
method = "POST",
url = minetest.settings:get(discord_webhook),
extra_headers = {"Content-Type: application/json"},
timeout = 5,
2021-11-28 21:00:27 +01:00
data = minetest.write_json({
username = discord_prefix,
avatar_url = "https://cdn.discordapp.com/avatars/447857790589992966/7ab615bae6196346bac795e66ba873dd.png",
content = msg,
}),
}, function() end)
end
end
2021-01-23 18:10:34 +01:00
minetest.register_chatcommand("x", {
params = "<msg>",
description = "Send a message on the staff channel",
2021-01-23 18:10:34 +01:00
privs = { kick = true },
func = function(name, param)
2021-11-28 21:00:27 +01:00
send_staff_message(string.format("<%s> %s", name, param), "[STAFF]: ", "Ingame Staff Channel", "server_chat_webhook")
end
})
2021-11-28 21:00:27 +01:00
ctf_report.send_report = function(msg)
send_staff_message(msg, "[REPORT]: ", "Ingame Report", "reports_webhook")
end