Code-Society-Lab / Code-Society-Lab/matrixpy
Check: `has_power_level`
- 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 has the required power level. Since it's a common pattern, we should implement a check for that in `checks.py`.
### Proposed API
```python
def has_power_level(level: int) -> Callable:
async def _has_power_level(ctx: Context) -> bool:
...
def wrapper(cmd: Command) -> Command:
cmd.check(_has_power_level)
```
**Example**
```python
from matrix.checks import is_admin
@has_power_level(100)
@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 with checks.py and the existing check patterns, then add unit tests under tests/ for the proposed has_power_level API. Done means the check enforces the requested power level and mypy, pytest tests/, and black . all pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- authorization
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100