raito.plugins.roles.manager moduleΒΆ

class raito.plugins.roles.manager.RoleManager(provider, developers=None)[source]ΒΆ

Bases: object

Central manager for role-based access control in Raito.

Parameters:
async migrate()[source]ΒΆ

Run provider migrations.

Return type:

None

async get_role(bot_id, user_id)[source]ΒΆ

Get the role for a specific user.

Parameters:
  • bot_id (int) – The Telegram bot ID

  • user_id (int) – The Telegram user ID

Returns:

The role slug or None if not found

Return type:

str | None

async can_manage_roles(bot_id, user_id)[source]ΒΆ

Check whether the user can manage other users’ roles.

Parameters:
  • bot_id (int) – The Telegram bot ID

  • user_id (int) – The Telegram user ID

Returns:

True if user can manage roles, False otherwise

Return type:

bool

async assign_role(bot_id, initiator_id, target_id, role_slug)[source]ΒΆ

Assign a role to a user.

Parameters:
  • bot_id (int) – The Telegram bot ID

  • initiator_id (int) – The Telegram user ID of the initiator

  • target_id (int) – The Telegram user ID of the target

  • role_slug (str) – The role to assign

Raises:

PermissionError – If the user does not have permission to assign role

Return type:

None

async revoke_role(bot_id, initiator_id, target_id)[source]ΒΆ

Revoke a user’s role.

Parameters:
  • bot_id (int) – The Telegram bot ID

  • initiator_id (int) – The Telegram user ID of the initiator

  • target_id (int) – The Telegram user ID of the target

Raises:

PermissionError – If the user does not have permission to revoke roles

Return type:

None

async has_any_roles(bot_id, user_id, *roles)[source]ΒΆ

Check if a user has any of the specified roles.

Parameters:
  • bot_id (int) – The Telegram bot ID

  • user_id (int) – The Telegram user ID

  • roles (str) – Roles to check for

Returns:

True if user has any of the roles, False otherwise

Return type:

bool

async has_role(bot_id, user_id, role_slug)[source]ΒΆ

Check if a user has the specified roles.

Parameters:
  • bot_id (int) – The Telegram bot ID

  • user_id (int) – The Telegram user ID

  • role_slug (str) – Role to check for

Returns:

True if user has the role, False otherwise

Return type:

bool

async get_users(bot_id, role)[source]ΒΆ

Get a list of users with a specific role.

Parameters:
  • bot_id (int) – The Telegram bot ID

  • role (str) – The role to check for

Returns:

A list of Telegram user IDs

Return type:

set[int]

property available_roles: list[RoleData]ΒΆ

Get a list of available roles.

Returns:

A list of roles

get_role_data(slug)[source]ΒΆ

Get data of specified role.

Returns:

A data of role

Raises:

…

Parameters:

slug (str)

Return type:

RoleData