v2.lua 893 B

123456789101112131415161718192021222324252627282930313233343536
  1. function xban.importers.v2()
  2. return pcall(function()
  3. local f, e = io.open(minetest.get_worldpath().."/players.iplist.v2")
  4. if not f then
  5. error("Unable to open `players.iplist.v2': "..e)
  6. end
  7. local text = f:read("*a")
  8. f:close()
  9. local db = minetest.deserialize(text)
  10. for _, ent in ipairs(db) do
  11. for name in pairs(ent.names) do
  12. local entry = xban.find_entry(name, true)
  13. if entry.source ~= "xban:importer_v2" then
  14. for nm in pairs(e.names) do
  15. entry.names[nm] = true
  16. end
  17. if ent.banned then
  18. entry.banned = true
  19. entry.reason = e.banned
  20. entry.source = "xban:importer_v2"
  21. entry.time = ent.time
  22. entry.expires = ent.expires
  23. table.insert(entry.record, {
  24. source = entry.source,
  25. reason = entry.reason,
  26. time = entry.time,
  27. expires = entry.expires,
  28. })
  29. end
  30. end
  31. end
  32. end
  33. end)
  34. end