Add react method to MaubotMessageEvent
This commit is contained in:
parent
66592ef81f
commit
d56ec94d34
1 changed files with 7 additions and 1 deletions
|
@ -21,7 +21,8 @@ import attr
|
||||||
from mautrix import Client as MatrixClient
|
from mautrix import Client as MatrixClient
|
||||||
from mautrix.util.formatter import parse_html
|
from mautrix.util.formatter import parse_html
|
||||||
from mautrix.types import (EventType, MessageEvent, Event, EventID, RoomID, MessageEventContent,
|
from mautrix.types import (EventType, MessageEvent, Event, EventID, RoomID, MessageEventContent,
|
||||||
MessageType, TextMessageEventContent, Format, RelatesTo, StateEvent)
|
MessageType, TextMessageEventContent, Format, RelatesTo, RelationType,
|
||||||
|
ReactionEventContent)
|
||||||
|
|
||||||
|
|
||||||
class EscapeHTML(Extension):
|
class EscapeHTML(Extension):
|
||||||
|
@ -70,6 +71,11 @@ class MaubotMessageEvent(MessageEvent):
|
||||||
def mark_read(self) -> Awaitable[None]:
|
def mark_read(self) -> Awaitable[None]:
|
||||||
return self.client.send_receipt(self.room_id, self.event_id, "m.read")
|
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):
|
class MaubotMatrixClient(MatrixClient):
|
||||||
def send_markdown(self, room_id: RoomID, markdown: str, msgtype: MessageType = MessageType.TEXT,
|
def send_markdown(self, room_id: RoomID, markdown: str, msgtype: MessageType = MessageType.TEXT,
|
||||||
|
|
Loading…
Reference in a new issue