diff --git a/chatcommands.lua b/chatcommands.lua index 2731338..2bc52d9 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -21,6 +21,16 @@ local create_channel = { func = function(lname, param) local lowner = lname + --check player privileges if plugin priv_cc is enabled + if minetest.settings:get_bool("beerchat.enable_priv_cc") then + local name_priv2cc = minetest.settings:get("beerchat.priv_cc.name") + if not (minetest.check_player_privs(lowner, name_priv2cc) or + minetest.check_player_privs(lowner, beerchat.admin_priv)) then + return false, "You don't have that privilege." + end + end + --end check priv_cc + if not param or param == "" then return false, "ERROR: Invalid number of arguments. Please supply the channel name as a minimum." end diff --git a/plugin/init.lua b/plugin/init.lua index d25a401..720c9a9 100644 --- a/plugin/init.lua +++ b/plugin/init.lua @@ -58,3 +58,6 @@ load_plugin("event-logging", true) -- Allows linking channels through channel aliases load_plugin("alias", false) + +-- Add special priv to use create_channel command +load_plugin("priv_cc", false) diff --git a/plugin/priv_cc.lua b/plugin/priv_cc.lua new file mode 100644 index 0000000..2ea04ed --- /dev/null +++ b/plugin/priv_cc.lua @@ -0,0 +1,8 @@ +-- if you need to set a special name for privilege, use "beerchat.name_priv_cc = spec_name" in minetest.conf +local name_priv2cc = minetest.settings:get("beerchat.priv_cc.name") +if name_priv2cc == '' then name_priv2cc = 'chat_creator' end +minetest.log("info", "to create channel add new priv: " .. name_priv2cc) +minetest.register_privilege(name_priv2cc, { + description = "Allows you to create a channel (mod beerchat)", + give_to_singleplayer = false +})