minetest.lua 699 B

123456789101112131415161718192021222324252627282930
  1. function xban.importers.minetest()
  2. local f, e = io.open(minetest.get_worldpath().."/ipban.txt")
  3. if not f then
  4. return false, "Unable to open `ipban.txt': "..e
  5. end
  6. for line in f:lines() do
  7. local ip, name = line:match("([^|]+)%|(.+)")
  8. if ip and name then
  9. local entry
  10. entry = xban.find_entry(ip, true)
  11. entry.banned = true
  12. entry.reason = "Banned in `ipban.txt'"
  13. entry.names[name] = true
  14. entry.names[ip] = true
  15. entry.time = os.time()
  16. entry.expires = nil
  17. entry.source = "xban:importer_minetest"
  18. table.insert(entry.record, {
  19. source = entry.source,
  20. reason = entry.reason,
  21. time = entry.time,
  22. expires = nil,
  23. })
  24. end
  25. end
  26. f:close()
  27. return true
  28. end