Support RoomMessageEmote events

This commit is contained in:
miruka 2019-07-19 19:19:43 -04:00
parent a10a395e0b
commit 58079a4ac2
2 changed files with 20 additions and 4 deletions

View File

@ -304,10 +304,24 @@ class MatrixClient(nio.AsyncClient):
ev.formatted_body ev.formatted_body
if ev.format == "org.matrix.custom.html" else html.escape(ev.body) if ev.format == "org.matrix.custom.html" else html.escape(ev.body)
) )
TimelineMessageReceived.from_nio(room, ev, content=co) TimelineMessageReceived.from_nio(room, ev, content=co)
async def onRoomMessageEmote(self, room, ev, from_past=False) -> None:
co = "%S {}".format(HTML_FILTER.filter_inline(
ev.formatted_body
if ev.format == "org.matrix.custom.html" else html.escape(ev.body)
))
TimelineEventReceived.from_nio(room, ev, content=co)
# async def onRoomMessageImage(self, room, ev, from_past=False) -> None:
# import json; print("RMI", json.dumps( ev.__dict__ , indent=4))
# async def onRoomEncryptedImage(self, room, ev, from_past=False) -> None:
# import json; print("REI", json.dumps( ev.__dict__ , indent=4))
async def onRoomCreateEvent(self, room, ev, from_past=False) -> None: async def onRoomCreateEvent(self, room, ev, from_past=False) -> None:
co = "%S allowed users on other matrix servers to join this room." \ co = "%S allowed users on other matrix servers to join this room." \
if ev.federate else \ if ev.federate else \
@ -444,12 +458,13 @@ class MatrixClient(nio.AsyncClient):
async def onOlmEvent(self, room, ev, from_past=False) -> None: async def onOlmEvent(self, room, ev, from_past=False) -> None:
co = f"%S hasn't sent your device the keys to decrypt this message." co = f"%S sent an undecryptable olm message."
TimelineEventReceived.from_nio(room, ev, content=co) TimelineEventReceived.from_nio(room, ev, content=co)
async def onMegolmEvent(self, room, ev, from_past=False) -> None: async def onMegolmEvent(self, room, ev, from_past=False) -> None:
await self.onOlmEvent(room, ev, from_past=False) co = f"%S sent an undecryptable message."
TimelineEventReceived.from_nio(room, ev, content=co)
async def onBadEvent(self, room, ev, from_past=False) -> None: async def onBadEvent(self, room, ev, from_past=False) -> None:

View File

@ -78,7 +78,8 @@ Item {
"@test_mary:matrix.org", "@test_mary:matrix.org",
"Rooms", "Rooms",
// "!TSXGsbBbdwsdylIOJZ:matrix.org" // st // "!TSXGsbBbdwsdylIOJZ:matrix.org" // st
"!VDSsFIzQnXARSCVNxS:matrix.org" // hs // "!VDSsFIzQnXARSCVNxS:matrix.org" // hs
"!XhxUcnVhVhUHkBZEIL:matrix.org" // nc
// "Invites", // "Invites",
// "!xjqvLOGhMVutPXpAqi:matrix.org" // "!xjqvLOGhMVutPXpAqi:matrix.org"
) )