Skip to content

Commit

Permalink
Add edits parameter to client.send_markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Sep 28, 2019
1 parent 7fcb7cb commit ccc94da
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions maubot/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,16 @@ def edit(self, content: Union[str, MessageEventContent],

class MaubotMatrixClient(MatrixClient):
def send_markdown(self, room_id: RoomID, markdown: str, msgtype: MessageType = MessageType.TEXT,
edits: Optional[Union[EventID, MessageEvent]] = None,
relates_to: Optional[RelatesTo] = None, **kwargs) -> Awaitable[EventID]:
content = TextMessageEventContent(msgtype=msgtype, format=Format.HTML)
content.body, content.formatted_body = parse_markdown(markdown)
if relates_to:
if edits:
raise ValueError("Can't use edits and relates_to at the same time.")
content.relates_to = relates_to
elif edits:
content.set_edit(edits)
return self.send_message(room_id, content, **kwargs)

async def dispatch_event(self, event: Event, source: SyncStream = SyncStream.INTERNAL) -> None:
Expand Down

0 comments on commit ccc94da

Please sign in to comment.