Browse Source

Add `.luacheckrc` and fix warnings.

master
Diego Martínez 6 years ago
parent
commit
89303b4a01
  1. 7
      .luacheckrc
  2. 8
      dbimport.lua
  3. 10
      importers/v2.lua
  4. 10
      init.lua

7
.luacheckrc

@ -0,0 +1,7 @@
unused_args = false
allow_defined_top = true
read_globals = {
"minetest",
}

8
dbimport.lua

@ -11,13 +11,13 @@ minetest.register_chatcommand("xban_dbi", {
privs = { server=true },
func = function(name, params)
if params == "--list" then
local names = { }
for name in pairs(xban.importers) do
table.insert(names, name)
local importers = { }
for importer in pairs(xban.importers) do
table.insert(importers, importer)
end
minetest.chat_send_player(name,
("[xban] Known importers: %s"):format(
table.concat(names, ", ")))
table.concat(importers, ", ")))
return
elseif not xban.importers[params] then
minetest.chat_send_player(name,

10
importers/v2.lua

@ -8,19 +8,19 @@ function xban.importers.v2()
local text = f:read("*a")
f:close()
local db = minetest.deserialize(text)
for _, e in ipairs(db) do
for name in pairs(e.names) do
for _, ent in ipairs(db) do
for name in pairs(ent.names) do
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
if e.banned then
if ent.banned then
entry.banned = true
entry.reason = e.banned
entry.source = "xban:importer_v2"
entry.time = e.time
entry.expires = e.expires
entry.time = ent.time
entry.expires = ent.expires
table.insert(entry.record, {
source = entry.source,
reason = entry.reason,

10
init.lua

@ -24,9 +24,7 @@ local function make_logger(level)
end
local ACTION = make_logger("action")
local INFO = make_logger("info")
local WARNING = make_logger("warning")
local ERROR = make_logger("error")
local unit_to_secs = {
s = 1, m = 60, h = 3600,
@ -299,11 +297,11 @@ minetest.register_chatcommand("xban_wl", {
local cmd, plname = params:match("%s*(%S+)%s*(%S+)")
if cmd == "add" then
xban.add_whitelist(plname, name)
ACTION("%s adds %s to whitelist", source, plname)
ACTION("%s adds %s to whitelist", name, plname)
return true, "Added to whitelist: "..plname
elseif cmd == "del" then
xban.remove_whitelist(plname)
ACTION("%s removes %s to whitelist", source, plname)
ACTION("%s removes %s to whitelist", name, plname)
return true, "Removed from whitelist: "..plname
elseif cmd == "get" then
local e = xban.get_whitelist(plname)
@ -361,10 +359,10 @@ local function load_db()
WARNING("Unable to load database: %s", "Read failed")
return
end
local t, e = minetest.deserialize(cont)
local t, e2 = minetest.deserialize(cont)
if not t then
WARNING("Unable to load database: %s",
"Deserialization failed: "..(e or "unknown error"))
"Deserialization failed: "..(e2 or "unknown error"))
return
end
db = t

Loading…
Cancel
Save