Skip to content

Check: can_redact #107

Description

@PenguinBoi12

Users have to implement manually a check to verify if a user performing a command can redact messages. Since it's a common pattern, we should implement a check for that in checks.py.

Proposed API

def can_redact() -> Callable:
    async def _can_redact(ctx: Context) -> bool:
        ...

    def wrapper(cmd: Command) -> Command:
        cmd.check(_can_redact)

Example

from matrix.checks import is_admin

@can_redact()
@bot.command()
async def kick(ctx, user: str) -> None:

Before opening a PR

  • Write unit tests
  • Run mypy
  • Run pytest tests/
  • Run black .

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions