diff options
Diffstat (limited to 'xban2')
-rw-r--r-- | xban2/.luacheckrc | 7 | ||||
-rw-r--r-- | xban2/dbimport.lua | 8 | ||||
-rw-r--r-- | xban2/importers/v2.lua | 10 | ||||
-rw-r--r-- | xban2/init.lua | 10 |
4 files changed, 20 insertions, 15 deletions
diff --git a/xban2/.luacheckrc b/xban2/.luacheckrc new file mode 100644 index 0000000..8ef1636 --- /dev/null +++ b/xban2/.luacheckrc @@ -0,0 +1,7 @@ + +unused_args = false +allow_defined_top = true + +read_globals = { + "minetest", +} diff --git a/xban2/dbimport.lua b/xban2/dbimport.lua index ec9293d..0d342bf 100644 --- a/xban2/dbimport.lua +++ b/xban2/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, diff --git a/xban2/importers/v2.lua b/xban2/importers/v2.lua index fd29966..739063f 100644 --- a/xban2/importers/v2.lua +++ b/xban2/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, diff --git a/xban2/init.lua b/xban2/init.lua index b3c42a6..dad13af 100644 --- a/xban2/init.lua +++ b/xban2/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 |