forked from cadence/out-of-your-element
Compare commits
2 commits
5aa13a2a92
...
b6a68936ec
| Author | SHA1 | Date | |
|---|---|---|---|
| b6a68936ec | |||
| 88b25e0482 |
2 changed files with 3 additions and 26 deletions
|
|
@ -4,37 +4,14 @@
|
|||
* 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, 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 {discord, sync, select, from} = require("../../passthrough")
|
||||
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.
|
||||
|
|
@ -59,7 +36,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. The user will just see a regular reply.",
|
||||
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.",
|
||||
"m.mentions": { "user_ids": [event.sender]},
|
||||
"m.relates_to": {
|
||||
event_id: threadEventID,
|
||||
|
|
|
|||
|
|
@ -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 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.",
|
||||
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.",
|
||||
format: "org.matrix.custom.html",
|
||||
formatted_body: "<strong><code>/thread</code> usage:</strong><br>Run this command as <code>/thread [Thread Name]</code> 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:<br><ul><li>If ran stand-alone (not as a reply, nor in a Matrix thread), the created thread will branch from the command-message itself. The <code>Thread Name</code> argument must be provided in this case, otherwise you get this help message.</li><li>If sent as a reply (outside a Matrix thread), the thread will branch from the message to which you replied.</li><li>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.</li></ul>"
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue