diff --git a/src/m2d/converters/threads-and-forums.js b/src/m2d/converters/threads-and-forums.js index dcf7909..d46ef49 100644 --- a/src/m2d/converters/threads-and-forums.js +++ b/src/m2d/converters/threads-and-forums.js @@ -4,14 +4,37 @@ * Misc. utils for transforming various Matrix events (eg. those sent in Forum-bridged channels; those sent) so that they're usable as threads, and for creating said threads. */ +const util = require("util") const Ty = require("../../types") -const {discord, sync, select, from} = require("../../passthrough") +const {discord, db, sync, as, select, from} = require("../../passthrough") +const {tag} = require("@cloudrac3r/html-template-tag") +const {Semaphore} = require("@chriscdn/promise-semaphore") +const assert = require("assert").strict const DiscordTypes = require("discord-api-types/v10") +/** @type {import("../actions/send-event")} */ +const sendEvent = sync.require("../actions/send-event") +/** @type {import("../actions/add-reaction")} */ +const addReaction = sync.require("../actions/add-reaction") +/** @type {import("../actions/redact")} */ +const redact = sync.require("../actions/redact") +/** @type {import("../actions/update-pins")}) */ +const updatePins = sync.require("../actions/update-pins") +/** @type {import("../actions/vote")}) */ +const vote = sync.require("../actions/vote") +/** @type {import("../../matrix/matrix-command-handler")} */ +const matrixCommandHandler = sync.require("../../matrix/matrix-command-handler") +/** @type {import("../../matrix/utils")} */ +const utils = sync.require("../../matrix/utils") /** @type {import("../../matrix/api")}) */ const api = sync.require("../../matrix/api") /** @type {import("../../d2m/actions/create-room")} */ const createRoom = sync.require("../../d2m/actions/create-room") +/** @type {import("../../matrix/room-upgrade")} */ +const roomUpgrade = require("../../matrix/room-upgrade") +/** @type {import("../../d2m/actions/retrigger")} */ +const retrigger = sync.require("../../d2m/actions/retrigger") +const {reg} = require("../../matrix/read-registration") /** * @param {Ty.Event.Outer_M_Room_Message | Ty.Event.Outer_M_Room_Message_File} event Used for determining the branching-point and the title; any relation data will be stripped and its room_id will mutate to the target thread-room, if one gets created. @@ -36,7 +59,7 @@ async function bridgeThread(event) { catch (e){ if (e.message?.includes("50024")){ //see: https://docs.discord.com/developers/topics/opcodes-and-status-codes api.sendEvent(event.room_id, "m.room.message", { - body: "Hey, please don't do that! This room is already a thread on Discord - trying to embed threads inside it will not work. DC users will just see a regular reply, which is distracting and also probably not what you want.", + body: "Hey, please don't do that! This room is already a thread on Discord - trying to embed threads inside it will not work. The user will just see a regular reply.", "m.mentions": { "user_ids": [event.sender]}, "m.relates_to": { event_id: threadEventID, diff --git a/src/matrix/matrix-command-handler.js b/src/matrix/matrix-command-handler.js index ba72d5a..e59e58c 100644 --- a/src/matrix/matrix-command-handler.js +++ b/src/matrix/matrix-command-handler.js @@ -276,7 +276,7 @@ const commands = [{ if (isFallingBack) return api.sendEvent(event.room_id, "m.room.message", { ...ctx, msgtype: "m.text", - body: "**`/thread` usage:**\nRun this command as `/thread [Thread Name]` to create a thread. The message from which said thread will branch, is chosen based on the following rules:\n* If ran stand-alone (not as a reply, nor in a Matrix thread), the created thread will branch from the command-message itself. The `Thread Name` argument must be provided in this case, otherwise you get this help message.\n* If sent as a reply (outside a Matrix thread), the thread will branch from the message to which you replied.\n* If ran inside an existing Matrix thread (regardless of whether it's a reply or not), the created Discord thread will be branching from the same message as the Matrix thread already is.", + body: "**`/thread` usage:**\nRun this command as `/thread [Thread Name]` to create a thread on Discord (and optionally Matrix, if one doesn't exist already). The message from which said thread will branch, is chosen based on the following rules:\n* If ran stand-alone (not as a reply, nor in a Matrix thread), the created thread will branch from the command-message itself. The `Thread Name` argument must be provided in this case, otherwise you get this help message.\n* If sent as a reply (outside a Matrix thread), the thread will branch from the message to which you replied.\n* If ran inside an existing Matrix thread (regardless of whether it's a reply or not), the created Discord thread will be branching from the same message as the Matrix thread already is.", format: "org.matrix.custom.html", formatted_body: "/thread usage:
Run this command as /thread [Thread Name] to create a thread on Discord (and optionally Matrix, if one doesn't exist already). The message from which said thread will branch, is chosen based on the following rules:
" })