From d56ec94d341a205b097694689e3cb1100c0ee404 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 21 Jun 2019 14:19:24 +0300 Subject: [PATCH] Add react method to MaubotMessageEvent --- maubot/matrix.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/maubot/matrix.py b/maubot/matrix.py index d75e522..99d67f9 100644 --- a/maubot/matrix.py +++ b/maubot/matrix.py @@ -21,7 +21,8 @@ import attr from mautrix import Client as MatrixClient from mautrix.util.formatter import parse_html from mautrix.types import (EventType, MessageEvent, Event, EventID, RoomID, MessageEventContent, - MessageType, TextMessageEventContent, Format, RelatesTo, StateEvent) + MessageType, TextMessageEventContent, Format, RelatesTo, RelationType, + ReactionEventContent) class EscapeHTML(Extension): @@ -70,6 +71,11 @@ class MaubotMessageEvent(MessageEvent): def mark_read(self) -> Awaitable[None]: return self.client.send_receipt(self.room_id, self.event_id, "m.read") + def react(self, key: str) -> Awaitable[None]: + content = ReactionEventContent(relates_to=RelatesTo(rel_type=RelationType.ANNOTATION, + event_id=self.event_id, key=key)) + return self.client.send_message_event(self.room_id, EventType.REACTION, content) + class MaubotMatrixClient(MatrixClient): def send_markdown(self, room_id: RoomID, markdown: str, msgtype: MessageType = MessageType.TEXT,