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
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
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 .
A
broadcastmethod could be a good way to let bot authors send announcements or notices to every room in a space without looping manually.Proposed API
Returns a list of
Messageobjects (one per room the message was successfully sent to), consistent with howRoom.sendworks.Example
Before opening a PR
mypy matrix/pytest tests/black .