From 44aafaa0b7663dde0d2e38c74cfabe884e94e729 Mon Sep 17 00:00:00 2001 From: Ashley Date: Tue, 27 Aug 2024 15:18:30 +0000 Subject: [PATCH] fix up some reply weirdness --- index.js | 2 +- lib/ext.js | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 283e63f..607b76a 100644 --- a/index.js +++ b/index.js @@ -106,7 +106,7 @@ client.on(sdk.RoomEvent.Timeline, async function (event, room, toStartOfTimeline var content = event.getContent(); - if(content["m.relates_to"] != null) + if(content["m.relates_to"] !== undefined) content.body = content.body.substring(content.body.indexOf("\n\n") + 2); event.sender = client.getRoom(event.sender.roomId).getMember(event.getSender()); diff --git a/lib/ext.js b/lib/ext.js index df295cc..a3d6000 100644 --- a/lib/ext.js +++ b/lib/ext.js @@ -26,6 +26,8 @@ export default function(client) { var content = event.getContent(); var mcontent = { + format: "org.matrix.custom.html", + formatted_body: "
In reply to " + event.sender.userId + "
" + (content.formatted_body ?? content.body) + "
" + (html ?? text).trim(), body: "> <" + event.sender.userId + "> " + content.body.split("\n")[0] + "\n\n" + text.trim(), msgtype: "m.notice", "m.relates_to": { @@ -35,14 +37,6 @@ export default function(client) { } }; - if(html) { - mcontent = { - format: "org.matrix.custom.html", - formatted_body: "
In reply to " + event.sender.userId + "
" + encode(content.body.split("\n")[0]) + "
" + html.trim(), - ...mcontent - } - } - client.sendEvent(event.event.room_id, "m.room.message", mcontent, "", (err, res) => { console.log(err); });