forked from cadence/out-of-your-element
get room mentions formatting working
This commit is contained in:
parent
0f4f404160
commit
5326b7d6be
6 changed files with 124 additions and 8 deletions
|
@ -20,11 +20,11 @@ function getDiscordParseCallbacks(message, useHTML) {
|
|||
}
|
||||
},
|
||||
channel: node => {
|
||||
const roomID = db.prepare("SELECT room_id FROM channel_room WHERE channel_id = ?").pluck().get(node.id)
|
||||
if (roomID && useHTML) {
|
||||
return "https://matrix.to/#/" + roomID
|
||||
const {room_id, name, nick} = db.prepare("SELECT room_id, name, nick FROM channel_room WHERE channel_id = ?").get(node.id)
|
||||
if (room_id && useHTML) {
|
||||
return `<a href="https://matrix.to/#/${room_id}">#${nick || name}</a>`
|
||||
} else {
|
||||
return "#" + node.id
|
||||
return `#${nick || name}`
|
||||
}
|
||||
},
|
||||
role: node =>
|
||||
|
|
|
@ -27,9 +27,9 @@ test("message2event: simple room mention", async t => {
|
|||
t.deepEqual(events, [{
|
||||
$type: "m.room.message",
|
||||
msgtype: "m.text",
|
||||
body: "@crunch god: Tell me about Phil, renowned martial arts master and creator of the Chin Trick",
|
||||
body: "#main",
|
||||
format: "org.matrix.custom.html",
|
||||
formatted_body: '<a href="https://matrix.to/#/@_ooye_crunch_god:cadence.moe">@crunch god</a> Tell me about Phil, renowned martial arts master and creator of the Chin Trick'
|
||||
formatted_body: '<a href="https://matrix.to/#/!kLRqKKUQXcibIMtOpl:cadence.moe">#main</a>'
|
||||
}])
|
||||
})
|
||||
|
||||
|
|
|
@ -12,8 +12,9 @@ const discordPackets = sync.require("./discord-packets")
|
|||
class DiscordClient {
|
||||
/**
|
||||
* @param {string} discordToken
|
||||
* @param {boolean} listen whether to set up the event listeners for OOYE to operate
|
||||
*/
|
||||
constructor(discordToken) {
|
||||
constructor(discordToken, listen) {
|
||||
this.discordToken = discordToken
|
||||
this.snow = new SnowTransfer(discordToken)
|
||||
this.cloud = new CloudStorm(discordToken, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue