Access

Summary
Access
otlib
otlib.InvalidCondition
Denied LevelsThis is used in InvalidCondition, a return from otlib.group.CheckAccess to specify what part of the access level an access check failed on.
InitCalled when a new InvalidCondition object is created by using the prototype as a functor.
SetLevelSets the level for this invalid condition, see Denied Levels.
GetLevelGets the level for the invalid condition, see Denied Levels.
SetParameterNumSets the parameter number the invalid condition occured on.
GetParameterNumGets the parameter number the invalid condition occured on, if applicable.
GetMessageGets the message for the invalid condition, if one has been created yet.
InvalidConditions
Access Registration
otlib.accessEach registered access represents a single permission.
RegisterRegisters a new access object.
Group Access
GetGroup
otlib.group
User Access
CheckAccessChecks if a user or group can use an access with specified, possibly parsed arguments.

otlib

otlib.InvalidCondition

Summary
Denied LevelsThis is used in InvalidCondition, a return from otlib.group.CheckAccess to specify what part of the access level an access check failed on.
InitCalled when a new InvalidCondition object is created by using the prototype as a functor.
SetLevelSets the level for this invalid condition, see Denied Levels.
GetLevelGets the level for the invalid condition, see Denied Levels.
SetParameterNumSets the parameter number the invalid condition occured on.
GetParameterNumGets the parameter number the invalid condition occured on, if applicable.
GetMessageGets the message for the invalid condition, if one has been created yet.
InvalidConditions

Denied Levels

This is used in InvalidCondition, a return from otlib.group.CheckAccess to specify what part of the access level an access check failed on.

DeniedLevel.NoAccessThe user has no access to this command at all.
DeniedLevel.ParametersThe specified arguments did not meet the requirements for the access being used.
DeniedLevel.UserParametersThe specified arguments met the hard requirements for the access being used, but not this particular user’s access to the command.

Init

function InvalidCondition:Init(...)

Called when a new InvalidCondition object is created by using the prototype as a functor.

Parameters

...If this immediate parent of this new object is InvalidCondition (setuping up a new invalid condition), this value should be a single string specifying the unformatted message for the condition.  Otherwise, if the condition is already setup, the values should be any number of any type which is directly passed into format on the unformatted string.

Revisions

v1.00Initial.

SetLevel

function InvalidCondition:SetLevel(level)

Sets the level for this invalid condition, see Denied Levels.

Parameters

levelThe level to set to.

Returns

Self.

Revisions

v1.00Initial.

GetLevel

function InvalidCondition:GetLevel()

Gets the level for the invalid condition, see Denied Levels.

Returns

The level.

Revisions

v1.00Initial.

SetParameterNum

function InvalidCondition:SetParameterNum(num)

Sets the parameter number the invalid condition occured on.

Parameters

numThe parameter number.

Returns

Self.

Revisions

v1.00Initial.

GetParameterNum

function InvalidCondition:GetParameterNum()

Gets the parameter number the invalid condition occured on, if applicable.

Returns

The parameter number or nil.  Nil is used when a parameter number is not applicable.

Revisions

v1.00Initial.

GetMessage

function InvalidCondition:GetMessage()

Gets the message for the invalid condition, if one has been created yet.

Returns

The string of the formatted message or nil if one has yet to be created.

Revisions

v1.00Initial.

InvalidConditions

AccessDeniedGiven when the user has no permission to the access at all.
NotSpecifiedGiven when there is no specified value and the argument is not optional.
TooHighGiven when the specified value is too high.
TooLowGiven when the specified value is too low.
InvalidGiven when the specified value is not a number.

Access Registration

otlib.access

Each registered access represents a single permission.  For example, you would want to register a separate access for each command, and you’d want to register a separate access for special actions such as the ability to hear admins’ private chat.

Summary
RegisterRegisters a new access object.

Register

function access:Register(tag,
...)

Registers a new access object.

Parameters

tagThe unique string name for this permission.
...Optional, any number of groups to give this permission to by default.

Returns

The newly registered access.

Revisions

v1.00Initial.

Group Access

Summary

GetGroup

function GetGroup(group)

otlib.group

Summary
User Access
CheckAccessChecks if a user or group can use an access with specified, possibly parsed arguments.

User Access

CheckAccess

function group:CheckAccess(access,
...)

Checks if a user or group can use an access with specified, possibly parsed arguments.  ‘Possibly parsed arguments’ simply means that numbers should come in as number or string types, bools as bools or strings, etc.

Parameters

accessThe access object to check permission against.
...Optional, any number of arguments of any type to check the permission against.

Returns

1A boolean of whether or not they have permission to the access object taking the specified parameters into account.
2An InvalidCondition object if they don’t have permission, a list table of the parsed arguments if they do.

Notes

  • It’s very important to remember that this function takes arguments into account.  They might have permission under certain circumstances, but if you don’t pass appropriate arguments in, it will still deny the access.  If you want to know if they’d have access under any circumstances, check the second return value.

Revisions

v1.00Initial.
function group:CheckAccess(access,
...)
Checks if a user or group can use an access with specified, possibly parsed arguments.
function InvalidCondition:Init(...)
Called when a new InvalidCondition object is created by using the prototype as a functor.
function InvalidCondition:SetLevel(level)
Sets the level for this invalid condition, see Denied Levels.
This is used in InvalidCondition, a return from otlib.group.CheckAccess to specify what part of the access level an access check failed on.
function InvalidCondition:GetLevel()
Gets the level for the invalid condition, see Denied Levels.
function InvalidCondition:SetParameterNum(num)
Sets the parameter number the invalid condition occured on.
function InvalidCondition:GetParameterNum()
Gets the parameter number the invalid condition occured on, if applicable.
function InvalidCondition:GetMessage()
Gets the message for the invalid condition, if one has been created yet.
function access:Register(tag,
...)
Registers a new access object.
function GetGroup(group)
Each registered access represents a single permission.
Close