From d47e87e390b018ac5510bb2143eb0e66f6bc2eeb Mon Sep 17 00:00:00 2001 From: Diego Martinez Date: Wed, 21 May 2014 07:07:37 -0300 Subject: Allow importing old databases. Currently: - Minetest (`ipban.txt') - xban v1 (`players.iplist') --- dbimport.lua | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 dbimport.lua (limited to 'dbimport.lua') diff --git a/dbimport.lua b/dbimport.lua new file mode 100644 index 0000000..22fef27 --- /dev/null +++ b/dbimport.lua @@ -0,0 +1,37 @@ + +xban.importers = { } + +dofile(xban.MP.."/importers/minetest.lua") +dofile(xban.MP.."/importers/v1.lua") + +minetest.register_chatcommand("xban_dbi", { + description = "Import old databases", + params = "", + privs = { server=true }, + func = function(name, params) + if params == "--list" then + local names = { } + for name in pairs(xban.importers) do + table.insert(names, name) + end + minetest.chat_send_player(name, + ("[xban] Known importers: %s"):format( + table.concat(names, ", "))) + return + elseif not xban.importers[params] then + minetest.chat_send_player(name, + ("[xban] Unknown importer `%s'"):format(params)) + minetest.chat_send_player(name, "[xban] Try `--list'") + return + end + local f = xban.importers[params] + local ok, err = f() + if ok then + minetest.chat_send_player(name, + "[xban] Import successfull") + else + minetest.chat_send_player(name, + ("[xban] Import failed: %s"):format(err)) + end + end, +}) -- cgit v1.2.3