Code-Society-Lab / Code-Society-Lab/matrixpy
Check: `can_redact`
- Dominant language
- Python
- Stars
- 14
- Forks
- 7
- Avg merge
- 8d 19h
- Merged PRs (30d)
- 5
Description
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
```python
def can_redact() -> Callable:
async def _can_redact(ctx: Context) -> bool:
...
def wrapper(cmd: Command) -> Command:
cmd.check(_can_redact)
```
**Example**
```python
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 .`
Contributor guide
Research direction
Start by reading checks.py to follow the existing check patterns, then inspect the relevant files under tests/. Implement the proposed can_redact API and add unit tests for its behavior; run pytest tests/, mypy, and black . to confirm the work is complete.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- authorization
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100