database.acl

Module Contents

Classes

ACL_group

Permission group.

ACL_rule

Permission rule.

ACL_rule_user

User constraint of the ACL_rule.

ACL_rule_group

Group constraint of the ACL_rule.

class database.acl.ACL_group

Permission group.

Groups are the connecting interface between Guilded roles and permission rules. They are meant to be organised in a trees:

VERIFIED      <id-of-role>
  BOOSTER     <id-of-role>
  MODERATORS
    MOD       <id-of-role>
    SUBMOD    <id-of-role>
GUEST         <id-of-role>

Note

See the ACL check function at core.acl.check().

See the command API at modules.base.acl.module.ACL.

idx
guild_id
name
parent
role_id
rules
dump(self) Dict[str, Union[int, str]]

Return object representation as dictionary for easy serialisation.

static add(guild_id: int, name: str, parent: Optional[str], role_id: Optional[int]) ACL_group

Add new permission group.

Parameters
  • guild_id – Guild ID.

  • name – Permission group name.

  • parent – Name of parent permission group. May be None.

  • role_id – ID for the Guilded Role. May be None to disable mapping from role to the group.

Returns

New group.

save(self)
static get(guild_id: int, name: str) Optional[ACL_group]

Get permission group.

Parameters
  • guild_id – Guild ID.

  • name – Name of the permisson group.

Returns

Found group or None.

static get_by_role(guild_id: int, role_id: int) Optional[ACL_group]

Get permission group by role ID.

Parameters
  • guild_id – Guild ID.

  • role_id – Role ID.

Returns

Found group or None.

static get_all(guild_id: int) List[ACL_group]

Get all permission groups in the guild.

Parameters

guild_id – Guild ID.

Returns

List of guild groups.

static remove(guild_id: int, name: str) int

Remove existing permission group.

Parameters
  • guild_id – Guild ID.

  • name – Group name.

Returns

Number of deleted groups, always 0 or 1.

class database.acl.ACL_rule

Permission rule.

Each rule holds information about the command, defaults (True or False), its guild (as ACL permissions are guild-dependent) and a list of Guilded users and ACL groups.

Note

See the ACL check function at core.acl.check().

See the command API at modules.base.acl.module.ACL.

idx
guild_id
command
default
users
groups
dump(self) Dict[str, Union[int, str, List[Union[int, str]]]]

Return object representation as dictionary for easy serialisation.

static add(guild_id: int, command: str, default: bool) ACL_rule

Add new permission rule.

Parameters
  • guild_id – Guild ID.

  • command – Qualified command name (see qualified_name attribute).

  • defaultTrue if the command should be usable by anyone by default, False otherwise.

Returns

New rule.

save(self) None
static get(guild_id: int, command: str) Optional[ACL_rule]

Get permission rule.

Parameters
  • guild_id – Guild ID.

  • command – Qualified command name (see qualified_name attribute).

Returns

Found permission rule or None.

static get_all(guild_id: int) List[ACL_rule]

Get all guild’s rules.

Parameters

guild_id – Guild ID.

Returns

List of permission rules.

static remove(guild_id: int, command: str) int

Remove permission rule.

Parameters
  • guild_id – Guild ID.

  • command – Qualified command name (see qualified_name attribute).

Returns

Number of deleted rules, always 0 or 1.

static remove_all(guild_id: int) int

Remove all permission rules.

Parameters

guild_id – Guild ID.

Returns

Number of deleted rules.

add_group(self, group_name: str, allow: bool) ACL_rule_group

Add group constraint to the rule.

Parameters
  • group_name – Name of permission group. Must be a group defined in the same guild as the rule.

  • allow – Whether to allow or deny the permission to given group.

Returns

Rule group constraint.

remove_group(self, group_name: str) int

Remove group constraint from the rule.

Parameters

group_name – Name of permission group. Must be a group defined in the same guild as the rule.

Returns

Number of removed group constraints, always 0 or 1.

add_user(self, user_id: int, allow: bool) ACL_rule_user

Add user constraint to the rule.

Parameters
  • user_id – User ID.

  • allow – Whether to allow or deny the permission to given user.

Returns

Rule user constraint.

remove_user(self, user_id: int) int

Remove user constraint from the rule.

Parameters

user_id – User ID.

Returns

Number of removed user constraints, always 0 or 1.

class database.acl.ACL_rule_user

User constraint of the ACL_rule.

See the check() function for more details.

idx
rule_idx
rule
user_id
allow
dump(self) Dict[str, Union[bool, int]]

Return object representation as dictionary for easy serialisation.

class database.acl.ACL_rule_group

Group constraint of the ACL_rule.

See the check() function for more details.

idx
rule_idx
rule
group_idx
group
allow
dump(self) Dict[str, Union[bool, int]]

Return object representation as dictionary for easy serialisation.