Merge branch 'feature/auth' into feature/standalone

Conflicts:
	luascripts/commands/admin/help.lua
This commit is contained in:
Timo Smit 2016-08-29 22:22:37 +02:00
commit a02f933722
36 changed files with 364 additions and 44 deletions

41
luascripts/auth/acl.lua Normal file
View file

@ -0,0 +1,41 @@
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
-- Copyright (C) 2015-2016 Timo 'Timothy' Smit
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- at your option any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local events = require "luascripts.wolfadmin.util.events"
local files = require "luascripts.wolfadmin.util.files"
local auth = require "luascripts.wolfadmin.auth.auth"
local acl = {}
function acl.readpermissions()
-- read level permissions into a cache file (can be loaded at mod start)
-- should probably cache current players' permissions as well, then
-- read in new players' permissions as they join the server
end
function acl.clearcache()
-- clear cache whenever database is updated, or do this manually
end
function acl.isallowed(clientId, permission)
-- stub function, reads from cache
return 1
end
return acl

127
luascripts/auth/auth.lua Normal file
View file

@ -0,0 +1,127 @@
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
-- Copyright (C) 2015-2016 Timo 'Timothy' Smit
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- at your option any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local events = require "luascripts.wolfadmin.util.events"
local files = require "luascripts.wolfadmin.util.files"
local settings = require "luascripts.wolfadmin.util.settings"
local auth = {}
local srv
auth.PERM_ADMINTEST = "admintest"
auth.PERM_HELP = "help"
auth.PERM_TIME = "time"
auth.PERM_GREETING = "greeting"
auth.PERM_LISTPLAYERS = "listplayers"
auth.PERM_LISTTEAMS = "listteams"
auth.PERM_LISTSPREES = "listsprees"
auth.PERM_LISTRULES = "listrules"
auth.PERM_LISTWARNS = "listwarns"
auth.PERM_LISTBANS = "listbans"
auth.PERM_LISTALIASES = "listaliases"
auth.PERM_LISTLEVELS = "listlevels"
auth.PERM_LISTSTATS = "liststats"
auth.PERM_FINGER = "finger"
auth.PERM_RESETXP = "resetxp"
auth.PERM_RESETXP_SELF = "resetxp_self"
auth.PERM_ADMINCHAT = "adminchat"
auth.PERM_PUT = "put"
auth.PERM_DROPWEAPONS = "dropweapons"
auth.PERM_RENAME = "rename"
auth.PERM_FREEZE = "freeze"
auth.PERM_DISORIENT = "disorient"
auth.PERM_BURN = "burn"
auth.PERM_GIB = "gib"
auth.PERM_THROW = "throw"
auth.PERM_GLOW = "glow"
auth.PERM_PANTS = "pants"
auth.PERM_POP = "pop"
auth.PERM_WARN = "warn"
auth.PERM_MUTE = "mute"
auth.PERM_VOICEMUTE = "voicemute"
auth.PERM_KICK = "kick"
auth.PERM_BAN = "ban"
auth.PERM_SPEC999 = "spec999"
auth.PERM_BALANCE = "balance"
auth.PERM_LOCKPLAYER = "lockplayers"
auth.PERM_LOCKTEAM = "lockteam"
auth.PERM_SHUFFLE = "shuffle"
auth.PERM_SWAP = "swap"
auth.PERM_PAUSE = "pause"
auth.PERM_NEXTMAP = "nextmap"
auth.PERM_RESTART = "restart"
auth.PERM_BOTADMIN = "botadmin"
auth.PERM_ENABLEVOTE = "enablevote"
auth.PERM_CANCELVOTE = "cancelvote"
auth.PERM_PASSVOTE = "passvote"
auth.PERM_NEWS = "news"
auth.PERM_UPTIME = "uptime"
auth.PERM_SETLEVEL = "setlevel"
auth.PERM_READCONFIG = "readconfig"
auth.PERM_CHEATS = "cheats"
auth.PERM_DISGUISE = "disguise" -- legacy
auth.PERM_AMMOPACK = "ammopack" -- legacy
auth.PERM_MEDPACK = "medpack" -- legacy
auth.PERM_REVIVE = "revive" -- legacy
auth.PERM_NOINACTIVITY = "noinactivity"
auth.PERM_NOVOTE = "novote"
auth.PERM_NOCENSOR = "nocensor"
auth.PERM_NOBALANCE = "nobalance"
auth.PERM_NOVOTELIMIT = "novotelimit"
auth.PERM_NOREASON = "noreason"
auth.PERM_PERMA = "perma"
auth.PERM_TEAMCMDS = "teamcmds"
auth.PERM_SILENTCMDS = "silentcmds"
auth.PERM_SPY = "spy"
auth.PERM_INCOGNITO = "incognito"
auth.PERM_IMMUNE = "immune"
-- as this module serves as a wrapper/super class, we load the selected database
-- system in this function. might have to think of a better way to implement
-- this, but it will suffice.
function auth.oninit()
if settings.get("g_standalone") == 1 then
srv = require "luascripts.wolfadmin.auth.acl"
else
srv = require "luascripts.wolfadmin.auth.shrubbot"
end
if settings.get("g_standalone") == 1 and et.trap_Cvar_Get("g_shrubbot") ~= "" then
outputDebug("Running in standalone mode while g_shrubbot is set", 3)
end
setmetatable(auth, {__index = srv})
end
events.handle("onGameInit", auth.oninit)
return auth

View file

@ -0,0 +1,114 @@
-- WolfAdmin module for Wolfenstein: Enemy Territory servers.
-- Copyright (C) 2015-2016 Timo 'Timothy' Smit
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- at your option any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local events = require "luascripts.wolfadmin.util.events"
local files = require "luascripts.wolfadmin.util.files"
local auth = require "luascripts.wolfadmin.auth.auth"
local shrubbot = {}
local flags = {
[auth.PERM_ADMINTEST] = "a",
[auth.PERM_HELP] = "h",
[auth.PERM_TIME] = "C",
[auth.PERM_GREETING] = "Q",
[auth.PERM_LISTPLAYERS] = "i",
[auth.PERM_LISTTEAMS] = "l",
[auth.PERM_LISTSPREES] = "I",
[auth.PERM_LISTRULES] = "C",
[auth.PERM_LISTWARNS] = "R",
[auth.PERM_LISTBANS] = "B",
[auth.PERM_LISTALIASES] = "f",
[auth.PERM_LISTLEVELS] = "s",
[auth.PERM_LISTSTATS] = "I",
[auth.PERM_FINGER] = "f",
[auth.PERM_RESETXP] = "X",
[auth.PERM_RESETXP_SELF] = "M",
[auth.PERM_ADMINCHAT] = "~",
[auth.PERM_PUT] = "p",
[auth.PERM_DROPWEAPONS] = "D",
[auth.PERM_RENAME] = "N",
[auth.PERM_FREEZE] = "E",
[auth.PERM_DISORIENT] = "d",
[auth.PERM_BURN] = "U",
[auth.PERM_GIB] = "g",
[auth.PERM_THROW] = "L",
[auth.PERM_GLOW] = "o",
[auth.PERM_PANTS] = "t",
[auth.PERM_POP] = "z",
[auth.PERM_WARN] = "R",
[auth.PERM_MUTE] = "m",
[auth.PERM_VOICEMUTE] = "m",
[auth.PERM_KICK] = "k",
[auth.PERM_BAN] = "b",
[auth.PERM_SPEC999] = "P",
[auth.PERM_BALANCE] = "p",
[auth.PERM_LOCKPLAYER] = "L",
[auth.PERM_LOCKTEAM] = "L",
[auth.PERM_SHUFFLE] = "S",
[auth.PERM_SWAP] = "w",
[auth.PERM_PAUSE] = "Z",
[auth.PERM_NEXTMAP] = "n",
[auth.PERM_RESTART] = "r",
[auth.PERM_BOTADMIN] = "O",
[auth.PERM_ENABLEVOTE] = "c",
[auth.PERM_CANCELVOTE] = "c",
[auth.PERM_PASSVOTE] = "V",
[auth.PERM_NEWS] = "W",
[auth.PERM_UPTIME] = "u",
[auth.PERM_SETLEVEL] = "s",
[auth.PERM_READCONFIG] = "G",
[auth.PERM_CHEATS] = "e",
[auth.PERM_DISGUISE] = "T",
[auth.PERM_AMMOPACK] = "J",
[auth.PERM_MEDPACK] = "J",
[auth.PERM_REVIVE] = "v",
[auth.PERM_NOINACTIVITY] = "0",
[auth.PERM_NOVOTE] = "1",
[auth.PERM_NOCENSOR] = "2",
[auth.PERM_NOBALANCE] = "5",
[auth.PERM_NOVOTELIMIT] = "7",
[auth.PERM_NOREASON] = "6",
[auth.PERM_PERMA] = "8",
[auth.PERM_TEAMCMDS] = "9",
[auth.PERM_SILENTCMDS] = "3",
[auth.PERM_SPY] = "4",
[auth.PERM_INCOGNITO] = "@",
[auth.PERM_IMMUNE] = "!",
}
function shrubbot.isallowed(clientId, permission)
return et.G_shrubbot_permission(clientId, flags[permission])
end
return shrubbot

View file

@ -16,6 +16,7 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local commands = require "luascripts.wolfadmin.commands.commands"
local auth = require "luascripts.wolfadmin.auth.auth"
local balancer = require "luascripts.wolfadmin.admin.balancer"
function commandBalance(clientId, cmdArguments)
@ -43,4 +44,4 @@ function commandBalance(clientId, cmdArguments)
return true
end
commands.addadmin("balance", commandBalance, "p", "either asks the players to even up or evens them by moving or shuffling players", "^2!balance ^9(^hforce^9)")
commands.addadmin("balance", commandBalance, auth.PERM_BALANCE, "either asks the players to even up or evens them by moving or shuffling players", "^2!balance ^9(^hforce^9)")

View file

@ -18,6 +18,7 @@
local db = require "luascripts.wolfadmin.db.db"
local settings = require "luascripts.wolfadmin.util.settings"
local commands = require "luascripts.wolfadmin.commands.commands"
local auth = require "luascripts.wolfadmin.auth.auth"
local warns = require "luascripts.wolfadmin.admin.warns"
function commandRemoveWarn(clientId, cmdArguments)
@ -57,4 +58,4 @@ function commandRemoveWarn(clientId, cmdArguments)
return true
end
commands.addadmin("dewarn", commandRemoveWarn, "R", "remove a warning for a certain player", "^9[^3name|slot#^9] ^9[^3warn#^9]", function() return (settings.get("g_warnHistory") == 0 or not db.isconnected()) end)
commands.addadmin("dewarn", commandRemoveWarn, auth.PERM_WARN, "remove a warning for a certain player", "^9[^3name|slot#^9] ^9[^3warn#^9]", function() return (settings.get("g_warnHistory") == 0 or not db.isconnected()) end)

View file

@ -16,6 +16,7 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local commands = require "luascripts.wolfadmin.commands.commands"
local auth = require "luascripts.wolfadmin.auth.auth"
local voting = require "luascripts.wolfadmin.game.voting"
function commandEnableVote(clientId, cmdArguments)
@ -25,4 +26,4 @@ function commandEnableVote(clientId, cmdArguments)
return true
end
commands.addadmin("enablevote", commandEnableVote, "c", "enables next map voting")
commands.addadmin("enablevote", commandEnableVote, auth.PERM_ENABLEVOTE, "enables next map voting")

View file

@ -16,6 +16,7 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local util = require "luascripts.wolfadmin.util.util"
local auth = require "luascripts.wolfadmin.auth.auth"
local commands = require "luascripts.wolfadmin.commands.commands"
local settings = require "luascripts.wolfadmin.util.settings"
local greetings = require "luascripts.wolfadmin.players.greetings"
@ -29,4 +30,4 @@ function commandGreeting(clientId, cmdArguments)
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dgreeting: ^9you do not have a personal greeting.\";")
end
end
commands.addadmin("greeting", commandGreeting, "Q", "display your personal greeting, if you have one")
commands.addadmin("greeting", commandGreeting, auth.PERM_GREETING, "display your personal greeting, if you have one")

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local commands = require "luascripts.wolfadmin.commands.commands"
local settings = require "luascripts.wolfadmin.util.settings"
@ -25,7 +26,7 @@ function commandHelp(clientId, cmdArguments)
local availableCommands = {}
for command, data in pairs(cmds) do
if data["function"] and data["flag"] and et.G_shrubbot_permission(clientId, data["flag"]) == 1 and (not data["hidden"] or (type(data["hidden"]) == "function" and not data["hidden"]())) then
if data["function"] and data["flag"] and auth.isallowed(clientId, data["flag"]) == 1 and (not data["hidden"] or (type(data["hidden"]) == "function" and not data["hidden"]())) then
table.insert(availableCommands, command)
end
end
@ -67,4 +68,8 @@ function commandHelp(clientId, cmdArguments)
return false
end
<<<<<<< HEAD
commands.addadmin("help", commandHelp, "h", "display commands available to you or help on a specific command", "^9(^hcommand^9)", true)
=======
commands.addadmin("help", commandHelp, auth.PERM_HELP, "display commands available to you or help on a specific command", "^9(^hcommand^9)", true)
>>>>>>> feature/auth

View file

@ -16,6 +16,7 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local commands = require "luascripts.wolfadmin.commands.commands"
local auth = require "luascripts.wolfadmin.auth.auth"
local stats = require "luascripts.wolfadmin.players.stats"
function commandIncognito(clientId, cmdArguments)
@ -37,7 +38,7 @@ function commandIncognito(clientId, cmdArguments)
-- et.G_Print(string.format("%s %s %d %s\n", adminName, adminGUID, adminLevel, adminFlags))
if stats.get(clientId, "playerGUID") == adminGUID then
if et.G_shrubbot_permission(clientId, "@") ~= 1 then
if auth.isallowed(clientId, "@") ~= 1 then
adminFlags = adminFlags.."+@"
et.trap_SendConsoleCommand(et.EXEC_APPEND, "cchat "..clientId.." \"^dincognito: ^9you are now playing incognito.\";")
@ -74,4 +75,4 @@ function commandIncognito(clientId, cmdArguments)
return true
end
commands.addadmin("incognito", commandIncognito, "s", "fakes your level to guest (no aka)")
commands.addadmin("incognito", commandIncognito, auth.PERM_INCOGNITO, "fakes your level to guest (no aka)")

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local commands = require "luascripts.wolfadmin.commands.commands"
local bots = require "luascripts.wolfadmin.game.bots"
@ -25,4 +26,4 @@ function commandBotsOff(clientId, cmdArguments)
return true
end
commands.addadmin("kickbots", commandBotsOff, "O", "kicks all bots from the game")
commands.addadmin("kickbots", commandBotsOff, auth.PERM_BOTADMIN, "kicks all bots from the game")

View file

@ -18,6 +18,7 @@
local util = require "luascripts.wolfadmin.util.util"
local settings = require "luascripts.wolfadmin.util.settings"
local pagination = require "luascripts.wolfadmin.util.pagination"
local auth = require "luascripts.wolfadmin.auth.auth"
local db = require "luascripts.wolfadmin.db.db"
local commands = require "luascripts.wolfadmin.commands.commands"
local stats = require "luascripts.wolfadmin.players.stats"
@ -47,7 +48,7 @@ function commandListAliases(clientId, cmdArguments)
return true
end
if et.G_shrubbot_permission(cmdClient, "!") == 1 then
if auth.isallowed(cmdClient, "!") == 1 then
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dlistaliases: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is immune to this command.\";")
return true
@ -76,4 +77,4 @@ function commandListAliases(clientId, cmdArguments)
return true
end
commands.addadmin("listaliases", commandListAliases, "f", "display all known aliases for a player", "^9[^3name|slot#^9] ^9(^hoffset^9)", function() return (not db.isconnected()) end)
commands.addadmin("listaliases", commandListAliases, auth.PERM_FINGER, "display all known aliases for a player", "^9[^3name|slot#^9] ^9(^hoffset^9)", function() return (not db.isconnected()) end)

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local util = require "luascripts.wolfadmin.util.util"
local settings = require "luascripts.wolfadmin.util.settings"
local pagination = require "luascripts.wolfadmin.util.pagination"
@ -93,4 +94,4 @@ function commandListLevels(clientId, cmdArguments)
return true
end
commands.addadmin("listlevels", commandListLevels, "s", "display all levels on the server", (not db.isconnected() and nil or "^9(^3name|slot#^9) ^9(^hoffset^9)"))
commands.addadmin("listlevels", commandListLevels, auth.PERM_LISTLEVELS, "display all levels on the server", (not db.isconnected() and nil or "^9(^3name|slot#^9) ^9(^hoffset^9)"))

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local util = require "luascripts.wolfadmin.util.util"
local commands = require "luascripts.wolfadmin.commands.commands"
local game = require "luascripts.wolfadmin.game.game"
@ -35,4 +36,4 @@ function commandListMaps(clientId, cmdArguments)
return true
end
commands.addadmin("listmaps", commandListMaps, "C", "display the maps in the rotation")
commands.addadmin("listmaps", commandListMaps, auth.PERM_LISTMAPS, "display the maps in the rotation")

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local util = require "luascripts.wolfadmin.util.util"
local constants = require "luascripts.wolfadmin.util.constants"
local commands = require "luascripts.wolfadmin.commands.commands"
@ -37,4 +38,4 @@ function commandLock(clientId, cmdArguments)
return false
end
commands.addadmin("lock", commandLock, "K", "lock one or all of the teams from players joining", "^9[^3r|b|s|all#^9]", true)
commands.addadmin("lock", commandLock, auth.PERM_LOCKTEAM, "lock one or all of the teams from players joining", "^9[^3r|b|s|all#^9]", true)

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local commands = require "luascripts.wolfadmin.commands.commands"
local bots = require "luascripts.wolfadmin.game.bots"
@ -25,4 +26,4 @@ function commandBotsOn(clientId, cmdArguments)
return true
end
commands.addadmin("needbots", commandBotsOn, "O", "adds bots to the game")
commands.addadmin("needbots", commandBotsOn, auth.PERM_BOTADMIN, "adds bots to the game")

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local util = require "luascripts.wolfadmin.util.util"
local commands = require "luascripts.wolfadmin.commands.commands"
local admin = require "luascripts.wolfadmin.admin.admin"
@ -45,7 +46,7 @@ function commandPlayerLock(clientId, cmdArguments)
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dplock: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is already locked to a team.\";")
return true
elseif et.G_shrubbot_permission(cmdClient, "!") == 1 then
elseif auth.isallowed(cmdClient, "!") == 1 then
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dplock: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is immune to this command.\";")
return true
@ -61,4 +62,4 @@ function commandPlayerLock(clientId, cmdArguments)
return true
end
commands.addadmin("plock", commandPlayerLock, "K", "locks a player to a specific team", "^9[^3name|slot#^9]")
commands.addadmin("plock", commandPlayerLock, auth.PERM_LOCKPLAYER, "locks a player to a specific team", "^9[^3name|slot#^9]")

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local util = require "luascripts.wolfadmin.util.util"
local commands = require "luascripts.wolfadmin.commands.commands"
local admin = require "luascripts.wolfadmin.admin.admin"
@ -53,4 +54,4 @@ function commandPlayerUnlock(clientId, cmdArguments)
return true
end
commands.addadmin("punlock", commandPlayerUnlock, "K", "unlocks a player", "^9[^3name|slot#^9]")
commands.addadmin("punlock", commandPlayerUnlock, auth.PERM_LOCKPLAYER, "unlocks a player", "^9[^3name|slot#^9]")

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local constants = require "luascripts.wolfadmin.util.constants"
local util = require "luascripts.wolfadmin.util.util"
local balancer = require "luascripts.wolfadmin.admin.balancer"
@ -51,4 +52,4 @@ function commandPutBots(clientId, cmdArguments)
return true
end
commands.addadmin("putbots", commandPutBots, "p", "puts all bots into a specific team", "^9[r|b|s]")
commands.addadmin("putbots", commandPutBots, auth.PERM_PUT, "puts all bots into a specific team", "^9[r|b|s]")

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local settings = require "luascripts.wolfadmin.util.settings"
local commands = require "luascripts.wolfadmin.commands.commands"
local rules = require "luascripts.wolfadmin.admin.rules"
@ -29,4 +30,4 @@ function commandReadconfig(clientId, cmdArguments)
return false
end
commands.addadmin("readconfig", commandReadconfig, "G", "reloads the shrubbot config file and refreshes user flags", nil, true)
commands.addadmin("readconfig", commandReadconfig, auth.PERM_READCONFIG, "reloads the shrubbot config file and refreshes user flags", nil, true)

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local db = require "luascripts.wolfadmin.db.db"
local commands = require "luascripts.wolfadmin.commands.commands"
local game = require "luascripts.wolfadmin.game.game"
@ -39,4 +40,4 @@ function commandResetSprees(clientId, cmdArguments)
return true
end
commands.addadmin("resetsprees", commandResetSprees, "G", "resets the spree records")
commands.addadmin("resetsprees", commandResetSprees, auth.PERM_READCONFIG, "resets the spree records")

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local commands = require "luascripts.wolfadmin.commands.commands"
local rules = require "luascripts.wolfadmin.admin.rules"
@ -42,4 +43,4 @@ function commandRules(clientId, cmdArguments)
return true
end
commands.addadmin("rules", commandRules, "C", "display the rules on the server", "^9(^hrule^9)")
commands.addadmin("rules", commandRules, auth.PERM_LISTRULES, "display the rules on the server", "^9(^hrule^9)")

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local settings = require "luascripts.wolfadmin.util.settings"
local db = require "luascripts.wolfadmin.db.db"
local commands = require "luascripts.wolfadmin.commands.commands"
@ -46,4 +47,4 @@ function commandSetLevel(clientId, cmdArguments)
return false
end
commands.addadmin("setlevel", commandSetLevel, "s", "sets the admin level of a player", "^9[^3name|slot#^9] ^9[^3level^9]", true)
commands.addadmin("setlevel", commandSetLevel, auth.PERM_SETLEVEL, "sets the admin level of a player", "^9[^3name|slot#^9] ^9[^3level^9]", true)

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local util = require "luascripts.wolfadmin.util.util"
local settings = require "luascripts.wolfadmin.util.settings"
local pagination = require "luascripts.wolfadmin.util.pagination"
@ -66,4 +67,4 @@ function commandShowWarns(clientId, cmdArguments)
return true
end
commands.addadmin("showwarns", commandShowWarns, "R", "display warnings for a specific player", "^9[^3name|slot#^9] ^9(^hoffset^9)", function() return (settings.get("g_warnHistory") == 0 or not db.isconnected()) end)
commands.addadmin("showwarns", commandShowWarns, auth.PERM_LISTWARNS, "display warnings for a specific player", "^9[^3name|slot#^9] ^9(^hoffset^9)", function() return (settings.get("g_warnHistory") == 0 or not db.isconnected()) end)

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local commands = require "luascripts.wolfadmin.commands.commands"
local db = require "luascripts.wolfadmin.db.db"
local sprees = require "luascripts.wolfadmin.game.sprees"
@ -44,4 +45,4 @@ function commandShowSprees(clientId, cmdArguments)
return true
end
commands.addadmin("sprees", commandShowSprees, "I", "display the current spree records")
commands.addadmin("sprees", commandShowSprees, auth.PERM_LISTSPREES, "display the current spree records")

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local util = require "luascripts.wolfadmin.util.util"
local commands = require "luascripts.wolfadmin.commands.commands"
@ -94,4 +95,4 @@ function commandShowStats(clientId, cmdArguments)
return true
end
commands.addadmin("stats", commandShowStats, "I", "display the statistics for a specific player", "^9[^3name|slot#^9]")
commands.addadmin("stats", commandShowStats, auth.PERM_LISTSTATS, "display the statistics for a specific player", "^9[^3name|slot#^9]")

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local util = require "luascripts.wolfadmin.util.util"
local constants = require "luascripts.wolfadmin.util.constants"
local commands = require "luascripts.wolfadmin.commands.commands"
@ -37,4 +38,4 @@ function commandUnlock(clientId, cmdArguments)
return false
end
commands.addadmin("unlock", commandUnlock, "K", "unlock one or all locked teams", "^9[^3r|b|s|all#^9]", true)
commands.addadmin("unlock", commandUnlock, auth.PERM_LOCKTEAM, "unlock one or all locked teams", "^9[^3r|b|s|all#^9]", true)

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local util = require "luascripts.wolfadmin.util.util"
local commands = require "luascripts.wolfadmin.commands.commands"
local admin = require "luascripts.wolfadmin.admin.admin"
@ -49,7 +50,7 @@ function commandVoiceMute(clientId, cmdArguments)
vmuteTime = util.getTimeFromString(cmdArguments[2])
elseif cmdArguments[2] then
vmuteReason = table.concat(cmdArguments, " ", 2)
elseif et.G_shrubbot_permission(clientId, "8") ~= 1 then
elseif auth.isallowed(clientId, "8") ~= 1 then
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dvmute usage: "..commands.getadmin("vmute")["syntax"].."\";")
return true
@ -59,7 +60,7 @@ function commandVoiceMute(clientId, cmdArguments)
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dvmute: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is already muted.\";")
return true
elseif et.G_shrubbot_permission(cmdClient, "!") == 1 then
elseif auth.isallowed(cmdClient, "!") == 1 then
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"^dvmute: ^7"..et.gentity_get(cmdClient, "pers.netname").." ^9is immune to this command.\";")
return true
@ -75,4 +76,4 @@ function commandVoiceMute(clientId, cmdArguments)
return true
end
commands.addadmin("vmute", commandVoiceMute, "m", "voicemutes a player", "^9[^3name|slot#^9]")
commands.addadmin("vmute", commandVoiceMute, auth.PERM_VOICEMUTE, "voicemutes a player", "^9[^3name|slot#^9]")

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local commands = require "luascripts.wolfadmin.commands.commands"
local admin = require "luascripts.wolfadmin.admin.admin"
@ -51,4 +52,4 @@ function commandVoiceUnmute(clientId, cmdArguments)
return true
end
commands.addadmin("vunmute", commandVoiceUnmute, "m", "unvoicemutes a player", "^9[^3name|slot#^9]")
commands.addadmin("vunmute", commandVoiceUnmute, auth.PERM_VOICEMUTE, "unvoicemutes a player", "^9[^3name|slot#^9]")

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local settings = require "luascripts.wolfadmin.util.settings"
local db = require "luascripts.wolfadmin.db.db"
local commands = require "luascripts.wolfadmin.commands.commands"
@ -41,4 +42,4 @@ function commandAddWarn(clientId, cmdArguments)
return false
end
commands.addadmin("warn", commandAddWarn, "R", "warns a player by displaying the reason", "^9[^3name|slot#^9] ^9[^3reason^9]", true)
commands.addadmin("warn", commandAddWarn, auth.PERM_WARN, "warns a player by displaying the reason", "^9[^3name|slot#^9] ^9[^3reason^9]", true)

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local commands = require "luascripts.wolfadmin.commands.commands"
function commandAdminChat(clientId, cmdArguments)
@ -29,7 +30,7 @@ function commandAdminChat(clientId, cmdArguments)
end
for playerId = 0, et.trap_Cvar_Get("sv_maxclients") - 1 do
if wolfa_isPlayer(playerId) and et.G_shrubbot_permission(playerId, "~") == 1 then
if wolfa_isPlayer(playerId) and auth.isallowed(playerId, "~") == 1 then
table.insert(recipients, playerId)
end
end
@ -45,5 +46,5 @@ function commandAdminChat(clientId, cmdArguments)
return true
end
commands.addclient("adminchat", commandAdminChat, "~", "[^2message^7]", true)
commands.addclient("ac", commandAdminChat, "~", "[^2message^7]", true)
commands.addclient("adminchat", commandAdminChat, auth.PERM_ADMINCHAT, "[^2message^7]", true)
commands.addclient("ac", commandAdminChat, auth.PERM_ADMINCHAT, "[^2message^7]", true)

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local commands = require "luascripts.wolfadmin.commands.commands"
local stats = require "luascripts.wolfadmin.players.stats"
@ -36,4 +37,4 @@ function commandPersonalMessage(clientId, cmdArguments)
end
end
commands.addclient("pm", commandPersonalMessage, "", "", true)
commands.addclient("m", commandPersonalMessage, "", "", true)
commands.addclient("m", commandPersonalMessage, "", "", true)

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local commands = require "luascripts.wolfadmin.commands.commands"
local stats = require "luascripts.wolfadmin.players.stats"
@ -52,4 +53,4 @@ function commandR(clientId, cmdArguments)
return true
end
commands.addclient("r", commandR, "", "[^2message^7]", true)
commands.addclient("r", commandR, "", "[^2message^7]", true)

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local commands = require "luascripts.wolfadmin.commands.commands"
function commandWolfAdmin(clientId, cmdArguments)
@ -27,4 +28,4 @@ function commandWolfAdmin(clientId, cmdArguments)
return true
end
commands.addclient("wolfadmin", commandWolfAdmin, "", "")
commands.addclient("wolfadmin", commandWolfAdmin, "", "")

View file

@ -21,6 +21,7 @@ local util = require "luascripts.wolfadmin.util.util"
local events = require "luascripts.wolfadmin.util.events"
local files = require "luascripts.wolfadmin.util.files"
local admin = require "luascripts.wolfadmin.admin.admin"
local auth = require "luascripts.wolfadmin.auth.auth"
local stats = require "luascripts.wolfadmin.players.stats"
local commands = {}
@ -194,7 +195,7 @@ function commands.onclientcommand(clientId, cmdText)
-- mod-specific or custom commands loading
if clientcmds[wolfCmd] and clientcmds[wolfCmd]["function"] and clientcmds[wolfCmd]["flag"] then
if clientcmds[wolfCmd]["flag"] == "" or et.G_shrubbot_permission(clientId, clientcmds[wolfCmd]["flag"]) == 1 then
if clientcmds[wolfCmd]["flag"] == "" or auth.isallowed(clientId, clientcmds[wolfCmd]["flag"]) == 1 then
for i = 1, et.trap_Argc() - 1 do
cmdArguments[i] = et.trap_Argv(i)
end
@ -272,7 +273,7 @@ function commands.onclientcommand(clientId, cmdText)
clientCmd = string.lower(clientCmd)
if clientcmds[clientCmd] and clientcmds[clientCmd]["function"] and clientcmds[clientCmd]["chat"] then
if clientcmds[clientCmd]["flag"] == "" or et.G_shrubbot_permission(clientId, clientcmds[clientCmd]["flag"]) == 1 then
if clientcmds[clientCmd]["flag"] == "" or auth.isallowed(clientId, clientcmds[clientCmd]["flag"]) == 1 then
return clientcmds[clientCmd]["function"](clientId, cmdArguments) and 1 or 0
end
end
@ -311,8 +312,8 @@ function commands.onclientcommand(clientId, cmdText)
shrubCmd = string.lower(shrubCmd)
if admincmds[shrubCmd] and admincmds[shrubCmd]["function"] and admincmds[shrubCmd]["flag"] then
if wolfCmd == "say" or (((wolfCmd == "say_team" and et.gentity_get(cmdClient, "sess.sessionTeam") ~= et.TEAM_SPECTATORS) or wolfCmd == "say_buddy") and et.G_shrubbot_permission(clientId, "9") == 1) or (wolfCmd == "!"..shrubCmd and et.G_shrubbot_permission(clientId, "3") == 1) then
if admincmds[shrubCmd]["flag"] ~= "" and et.G_shrubbot_permission(clientId, admincmds[shrubCmd]["flag"]) == 1 then
if wolfCmd == "say" or (((wolfCmd == "say_team" and et.gentity_get(cmdClient, "sess.sessionTeam") ~= et.TEAM_SPECTATORS) or wolfCmd == "say_buddy") and auth.isallowed(clientId, auth.PERM_TEAMCMDS) == 1) or (wolfCmd == "!"..shrubCmd and auth.isallowed(clientId, auth.PERM_SILENTCMDS) == 1) then
if admincmds[shrubCmd]["flag"] ~= "" and auth.isallowed(clientId, admincmds[shrubCmd]["flag"]) == 1 then
local isFinished = admincmds[shrubCmd]["function"](clientId, cmdArguments)
if not admincmds[shrubCmd]["hidden"] then
@ -333,4 +334,4 @@ function commands.onclientcommand(clientId, cmdText)
end
events.handle("onClientCommand", commands.onclientcommand)
return commands
return commands

View file

@ -15,6 +15,7 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local constants = require "luascripts.wolfadmin.util.constants"
local util = require "luascripts.wolfadmin.util.util"
local events = require "luascripts.wolfadmin.util.events"
@ -88,7 +89,7 @@ events.handle("onGameStateChange", voting.ongamestatechange)
function voting.oncallvote(clientId, type, args)
if et.gentity_get(clientId, "sess.sessionTeam") == constants.TEAM_SPECTATORS or args[1] == "?" then
return 0
elseif voting.isrestricted(type) and et.G_shrubbot_permission(clientId, "%") ~= 1 then
elseif voting.isrestricted(type) and auth.isallowed(clientId, PERM_NOVOTELIMIT) ~= 1 then
et.trap_SendConsoleCommand(et.EXEC_APPEND, "csay "..clientId.." \"callvote: you are not allowed to call this type of vote.\";")
et.trap_SendServerCommand(clientId, "cp \"You are not allowed to call this type of vote.")

View file

@ -15,6 +15,8 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local auth = require "luascripts.wolfadmin.auth.auth"
local constants = require "luascripts.wolfadmin.util.constants"
local util = require "luascripts.wolfadmin.util.util"
local events = require "luascripts.wolfadmin.util.events"
@ -31,7 +33,7 @@ local levelGreetings = {}
function greetings.get(clientId)
local lvl = et.G_shrubbot_level(clientId)
if et.G_shrubbot_permission(clientId, "@") ~= 1 then
if auth.isallowed(clientId, auth.PERM_INCOGNITO) ~= 1 then
if userGreetings[stats.get(clientId, "playerGUID")] ~= nil then
return userGreetings[stats.get(clientId, "playerGUID")]
elseif levelGreetings[lvl] ~= nil then