chatops.permissions module

Permissions utilities for ChatOps commands.

  • Admin allowlist via ENV ADMIN_USER_IDS (comma-separated integers)

  • Optional chat allowlist via ENV ALLOWED_CHAT_IDS (comma-separated integers)

  • Decorators for admin-only and chat-allowlisted commands

chatops.permissions.get_admin_user_ids()[מקור]
Return type:

Set[int]

chatops.permissions.is_admin(user_id)[מקור]

Return True if user is admin.

Behavior when ADMIN_USER_IDS is empty: - By default (secure), no user is considered admin - If CHATOPS_ALLOW_ALL_IF_NO_ADMINS=1, treat empty allowlist as no restriction (all users admin)

Return type:

bool

פרמטרים:

user_id (int)

chatops.permissions.get_allowed_chat_ids()[מקור]
Return type:

Set[int]

chatops.permissions.is_chat_allowed(chat_id)[מקור]
Return type:

bool

פרמטרים:

chat_id (int | None)

chatops.permissions.admin_required(func)[מקור]
Return type:

Callable[..., Awaitable[Any]]

פרמטרים:

func (Callable[[...], Awaitable[Any]])

chatops.permissions.chat_allowlist_required(func)[מקור]
Return type:

Callable[..., Awaitable[Any]]

פרמטרים:

func (Callable[[...], Awaitable[Any]])