raito.plugins.roles.manager module

class raito.plugins.roles.manager.RoleManager(provider, developers=None)[исходный код]

Базовые классы: object

Central manager for role-based access control in Raito.

Параметры:
async migrate()[исходный код]

Run provider migrations.

Тип результата:

None

async get_role(bot_id, user_id)[исходный код]

Get the role for a specific user.

Параметры:
  • bot_id (int) – The Telegram bot ID

  • user_id (int) – The Telegram user ID

Результат:

The role slug or None if not found

Тип результата:

str | None

async can_manage_roles(bot_id, user_id)[исходный код]

Check whether the user can manage other users“ roles.

Параметры:
  • bot_id (int) – The Telegram bot ID

  • user_id (int) – The Telegram user ID

Результат:

True if user can manage roles, False otherwise

Тип результата:

bool

async assign_role(bot_id, initiator_id, target_id, role_slug)[исходный код]

Assign a role to a user.

Параметры:
  • 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

Исключение:

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

Тип результата:

None

async revoke_role(bot_id, initiator_id, target_id)[исходный код]

Revoke a user’s role.

Параметры:
  • 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

Исключение:

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

Тип результата:

None

async has_any_roles(bot_id, user_id, *roles)[исходный код]

Check if a user has any of the specified roles.

Параметры:
  • bot_id (int) – The Telegram bot ID

  • user_id (int) – The Telegram user ID

  • roles (str) – Roles to check for

Результат:

True if user has any of the roles, False otherwise

Тип результата:

bool

async has_role(bot_id, user_id, role_slug)[исходный код]

Check if a user has the specified roles.

Параметры:
  • bot_id (int) – The Telegram bot ID

  • user_id (int) – The Telegram user ID

  • role_slug (str) – Role to check for

Результат:

True if user has the role, False otherwise

Тип результата:

bool

async get_users(bot_id, role)[исходный код]

Get a list of users with a specific role.

Параметры:
  • bot_id (int) – The Telegram bot ID

  • role (str) – The role to check for

Результат:

A list of Telegram user IDs

Тип результата:

set[int]

property available_roles: list[RoleData]

Get a list of available roles.

Результат:

A list of roles

get_role_data(slug)[исходный код]

Get data of specified role.

Результат:

A data of role

Raises:

Параметры:

slug (str)

Тип результата:

RoleData