From 1dca8d6659fabca58fb043177c62adc570e0aec6 Mon Sep 17 00:00:00 2001 From: bertybuttface <110790513+bertybuttface@users.noreply.github.com> Date: Fri, 27 Oct 2023 17:20:57 +0100 Subject: [PATCH] Update index.ts --- src/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index b1a0deb..3a618a6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -76,7 +76,12 @@ async function main() { client.on("room.failed_decryption", async (roomId, event, error) => { // handle `m.room.encrypted` event that could not be decrypted LogService.error("index", `Failed decryption event!\n${{ roomId, event, error }}`); - await client.sendText(roomId, `I couldn't decrypt the message :( Please add me to an unencrypted room.`); + await client.sendText(roomId, `Room key error. I will leave the room, please reinvite me!`); + try { + await client.leaveRoom(roomId); + } catch (e) { + LogService.error("index", `Failed to leave room ${roomId} after failed decryption!`); + } }); client.on("room.join", async (roomId: string, _event: any) => {