xban2/importers/v2.lua

36 lines
893 B
Lua
Raw Normal View History

2014-06-26 08:17:40 +02:00
function xban.importers.v2()
return pcall(function()
local f, e = io.open(minetest.get_worldpath().."/players.iplist.v2")
if not f then
error("Unable to open `players.iplist.v2': "..e)
end
local text = f:read("*a")
f:close()
local db = minetest.deserialize(text)
2017-02-17 06:30:30 +01:00
for _, ent in ipairs(db) do
for name in pairs(ent.names) do
2014-06-26 08:17:40 +02:00
local entry = xban.find_entry(name, true)
if entry.source ~= "xban:importer_v2" then
for nm in pairs(e.names) do
entry.names[nm] = true
end
2017-02-17 06:30:30 +01:00
if ent.banned then
2014-06-26 08:17:40 +02:00
entry.banned = true
entry.reason = e.banned
entry.source = "xban:importer_v2"
2017-02-17 06:30:30 +01:00
entry.time = ent.time
entry.expires = ent.expires
2014-06-26 08:17:40 +02:00
table.insert(entry.record, {
source = entry.source,
reason = entry.reason,
time = entry.time,
expires = entry.expires,
})
end
end
end
end
end)
end