Code-Society-Lab / Code-Society-Lab/matrixpy
Space: Add a `broadcast` method
- Dominant language
- Python
- Stars
- 14
- Forks
- 7
- Avg merge
- 8d 19h
- Merged PRs (30d)
- 5
Description
A `broadcast` method could be a good way to let bot authors send announcements or notices to every room in a space without looping manually.
### Proposed API
```python
async def broadcast(
self,
content: str,
*,
raw: bool = False,
notice: bool = False,
) -> list[Message]:
```
Returns a list of `Message` objects (one per room the message was successfully sent to), consistent with how `Room.send` works.
### Example
```python
space = bot.get_space("!space123:matrix.org")
messages = await space.broadcast("Maintenance starts in 10 minutes.", notice=True)
```
### Before opening a PR
- Write unit tests
- Run `mypy matrix/`
- Run `pytest tests/`
- Run `black .`
Contributor guide
Assessment
This issue has not been assessed yet.