1 local http, env, storage
2 local C = minetest.get_color_escape_sequence
4 function furrybot.is_operator(name)
5 return name == minetest.localplayer:get_name() or furrybot.operators[name]
8 function furrybot.operator_command(cmd, func)
9 furrybot.commands[cmd] = function (name, ...)
10 if furrybot.is_operator(name) then
13 furrybot.error_message(name, "Sorry, you need to be an operator run this command: ", cmd)
16 furrybot.unsafe_commands[cmd] = true
19 function furrybot.status_command(cmd, list_name, title, status)
20 furrybot.operator_command(cmd, function(name, target)
22 if furrybot[list_name][target] == status then
23 furrybot.error_message(name, "Player " .. (status and "already" or "not") .. " " .. title .. ": ", target)
25 furrybot[list_name][target] = status
26 storage:set_string(list_name, minetest.serialize(furrybot[list_name]))
27 furrybot.ping_message(name, "Successfully " .. cmd .. (cmd:sub(#cmd, #cmd) == "e" and "" or "e") .. "d " .. target, furrybot.colors.system)
30 furrybot.error_message(name, "You need to specify a player")
35 function furrybot.list_command(list_name, title)
39 for name in pairs(furrybot[list_name]) do
40 table.insert(names, name)
43 furrybot.send("List of " .. title .. ": " .. table.concat(names, ", "), furrybot.colors.system)
47 furrybot.operator_command("reload", function()
48 furrybot.reload(http, env, storage)
51 furrybot.operator_command("disconnect", function()
55 furrybot.status_command("op", "operators", "an operator", true)
56 furrybot.status_command("deop", "operators", "an operator", nil)
57 furrybot.commands.oplist = furrybot.list_command("operators", "operators")
59 furrybot.status_command("ignore", "ignored", "ignored", true)
60 furrybot.status_command("unignore", "ignored", "ignored", nil)
61 furrybot.commands.ignorelist = furrybot.list_command("ignored", "ignored players")
63 return function(_http, _env, _storage)
64 http, env, storage = _http, _env, _storage
66 furrybot.operators = minetest.deserialize(storage:get_string("operators")) or {}
67 furrybot.ignored = minetest.deserialize(storage:get_string("ignored")) or {}