Skip to content

Space: Add a broadcast method #66

Description

@PenguinBoi12

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 .

Metadata

Metadata

Assignees

Labels

Fields

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions