Code-Society-Lab / Code-Society-Lab/matrixpy

Check: `can_invite`

Open
#106 0 comments 0 reactions 0 assignees View on GitHub
feature good first issue
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 invite. Since it's a common pattern, we should implement a check for that in `checks.py`.

### Proposed API
```python
def can_invite() -> Callable:
async def _can_invite(ctx: Context) -> bool:
...

def wrapper(cmd: Command) -> Command:
cmd.check(_can_invite)
```

**Example**
```python
from matrix.checks import is_admin

@can_invite()
@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

Open the contributing guide

Research direction

Start in checks.py by reading the existing check implementations and compare them with the proposed can_invite API and command example. Add unit tests under tests/ that cover the new check, then run pytest tests/, mypy, and black .; done means the check is available with the documented decorator behavior.

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
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.