2023-06-22 00:24:06 -04:00
|
|
|
-- mod governor by mckaygerhard - commands module
|
2023-06-09 23:40:06 -04:00
|
|
|
-- Copyright 2020
|
|
|
|
|
|
|
|
----------------------------------------------------------------------------
|
|
|
|
-- this program can be used free but cannot be used commertially or
|
2023-06-22 00:24:06 -04:00
|
|
|
-- modified for, licenced CC-BY-SA-NC 4.0 unless explicit permission
|
2023-06-09 23:40:06 -04:00
|
|
|
|
|
|
|
-- This program is distributed in the hope that it will be useful,
|
|
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
----------------------------------------------------------------------------
|
|
|
|
|
2023-06-22 16:07:14 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--[[ commands for killme implementation no matter of those mods ]]
|
|
|
|
|
2023-06-22 00:59:28 -04:00
|
|
|
if not governing.modkillme and not governing.modcommand then
|
2023-06-20 11:41:04 -04:00
|
|
|
minetest.register_chatcommand("killme", {
|
|
|
|
description = "Kill player or yourselft to respawn",
|
|
|
|
func = function(name)
|
|
|
|
local player = minetest.get_player_by_name(name)
|
|
|
|
if player then
|
|
|
|
if minetest.settings:get_bool("enable_damage") and player:is_player() then
|
|
|
|
player:set_hp(0)
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
for _, callback in pairs(minetest.registered_on_respawnplayers) do
|
|
|
|
if callback(player) then
|
|
|
|
return true
|
|
|
|
end
|
2023-06-09 23:40:06 -04:00
|
|
|
end
|
2023-06-20 11:41:04 -04:00
|
|
|
-- There doesn't seem to be a way to get a default spawn pos from the lua API
|
|
|
|
return false, "No static_spawnpoint defined"
|
2023-06-09 23:40:06 -04:00
|
|
|
end
|
2023-06-20 11:41:04 -04:00
|
|
|
else
|
|
|
|
-- Show error message if used when not logged in, eg: from IRC mod
|
|
|
|
return false, "You need to be online to be killed!"
|
2023-06-09 23:40:06 -04:00
|
|
|
end
|
|
|
|
end
|
2023-06-20 11:41:04 -04:00
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2023-06-22 16:07:14 -04:00
|
|
|
--[[ end of commands for killme implementation no matter of those mods ]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- -----------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
--[[ commands for geoip and ip location information ]]
|
2023-06-21 15:39:10 -04:00
|
|
|
|
|
|
|
if not governing.modgeoip then
|
|
|
|
minetest.register_chatcommand("geoip", {
|
|
|
|
params = "<playername>",
|
|
|
|
privs = {geoip=true},
|
|
|
|
description = "Does a geoip lookup on the given player for governing",
|
|
|
|
func = function(name, param)
|
|
|
|
|
|
|
|
if not param then return true, "usage: /geoip <playername>" end
|
2023-06-21 18:01:36 -04:00
|
|
|
if not minetest.get_player_ip then return true, "[geoip]: engine its too older, canot get ip of player." end
|
2023-06-21 15:39:10 -04:00
|
|
|
|
|
|
|
local ip = minetest.get_player_ip(param)
|
2023-06-21 18:01:36 -04:00
|
|
|
if not ip then return true, "[geoip] no ip available! seems "..param.." does not provide such info!" end
|
2023-06-21 15:39:10 -04:00
|
|
|
|
|
|
|
governing.lookup(ip, function(result)
|
2023-06-21 22:00:15 -04:00
|
|
|
local txt = format_result_geoip(result)
|
2023-06-21 18:01:36 -04:00
|
|
|
if not txt then return true, "[geoip]: "..param..":"..ip" error: "..(result.description or "unknown error") end
|
|
|
|
minetest.log("action", "[geoip] "..param..": "..txt)
|
|
|
|
minetest.chat_send_player(name, param..": "..txt)
|
2023-06-21 15:39:10 -04:00
|
|
|
end)
|
|
|
|
|
|
|
|
end
|
|
|
|
})
|
|
|
|
end
|
2023-06-21 22:00:15 -04:00
|
|
|
|
2023-06-22 00:24:06 -04:00
|
|
|
minetest.register_chatcommand("govip", {
|
|
|
|
params = "<playername>",
|
|
|
|
privs = {governing=true},
|
|
|
|
description = "Governing geoip lookup + net detection details on the given player",
|
|
|
|
func = function(name, param)
|
|
|
|
if not param then return true, "usage: /govip <playername>" end
|
|
|
|
if not minetest.get_player_ip then return true, "[governing]: engine its too older, canot get ip of player." end
|
|
|
|
local ip = minetest.get_player_ip(param)
|
|
|
|
if not ip then return true, "[governing] no ip available! seems "..param.." does not provide such info!" end
|
|
|
|
governing.checkip(ip, function(result)
|
2023-06-22 16:07:14 -04:00
|
|
|
local txt = format_result_checkip(result)
|
|
|
|
if not txt then return true, "[governing]: "..param..":"..ip" error: "..(result.description or "unknown error") end
|
|
|
|
minetest.log("action", "[governing] "..param..": "..txt)
|
|
|
|
minetest.chat_send_player(name, param..": "..txt)
|
|
|
|
end)
|
2023-06-22 00:24:06 -04:00
|
|
|
end
|
|
|
|
})
|
|
|
|
|
2023-06-22 16:07:14 -04:00
|
|
|
--[[ end of commands for geoip and ip location information ]]
|
|
|
|
|
|
|
|
|
|
|
|
|