From 0237d45c60e2a325892c00fed17fc1175374c107 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Thu, 7 Sep 2023 12:07:56 +1200 Subject: [PATCH] support uk.half-shot.bridge --- d2m/actions/create-room.js | 20 ++++++++++++++++++++ matrix/file.js | 1 + 2 files changed, 21 insertions(+) diff --git a/d2m/actions/create-room.js b/d2m/actions/create-room.js index 30de4f3..e8284df 100644 --- a/d2m/actions/create-room.js +++ b/d2m/actions/create-room.js @@ -110,6 +110,23 @@ async function channelToKState(channel, guild) { }, "chat.schildi.hide_ui/read_receipts": { hidden: true + }, + [`uk.half-shot.bridge/moe.cadence.ooye://discord/${guild.id}/${channel.id}`]: { + bridgebot: `@${reg.sender_localpart}:${reg.ooye.server_name}`, + protocol: { + id: "discord", + displayname: "Discord" + }, + network: { + id: guild.id, + displayname: guild.name, + avatar_url: file.DISCORD_IMAGES_BASE + file.guildIcon(guild) + }, + channel: { + id: channel.id, + displayname: channel.name, + external_url: `https://discord.com/channels/${guild.id}/${channel.id}` + } } } @@ -295,6 +312,9 @@ async function _unbridgeRoom(channelID) { await api.sendState(roomID, "m.space.parent", spaceID, {}) await api.sendState(spaceID, "m.space.child", roomID, {}) + // remove declaration that the room is bridged + await api.sendState(roomID, "uk.half-shot.bridge", `moe.cadence.ooye://discord/${channel.guild_id}/${channel.id}`, {}) + // send a notification in the room await api.sendEvent(roomID, "m.room.message", { msgtype: "m.notice", diff --git a/matrix/file.js b/matrix/file.js index 7d74d5d..e431a36 100644 --- a/matrix/file.js +++ b/matrix/file.js @@ -99,6 +99,7 @@ function sticker(sticker) { return `/stickers/${sticker.id}.${ext}` } +module.exports.DISCORD_IMAGES_BASE = DISCORD_IMAGES_BASE module.exports.guildIcon = guildIcon module.exports.userAvatar = userAvatar module.exports.memberAvatar = memberAvatar