2023-04-25 20:06:08 +00:00
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
const markdown = require("discord-markdown")
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {import("discord-api-types/v10").APIMessage} message
|
2023-05-08 11:37:51 +00:00
|
|
|
* @returns {import("../../types").Event.M_Room_Message}
|
2023-04-25 20:06:08 +00:00
|
|
|
*/
|
2023-05-05 05:29:08 +00:00
|
|
|
function messageToEvent(message) {
|
2023-04-25 20:06:08 +00:00
|
|
|
const body = message.content
|
|
|
|
const html = markdown.toHTML(body, {
|
2023-04-30 12:57:30 +00:00
|
|
|
/* discordCallback: {
|
2023-04-25 20:06:08 +00:00
|
|
|
user: Function,
|
|
|
|
channel: Function,
|
|
|
|
role: Function,
|
|
|
|
everyone: Function,
|
|
|
|
here: Function
|
2023-04-30 12:57:30 +00:00
|
|
|
} */
|
2023-04-25 20:06:08 +00:00
|
|
|
}, null, null)
|
|
|
|
return {
|
|
|
|
msgtype: "m.text",
|
|
|
|
body: body,
|
2023-04-30 12:57:30 +00:00
|
|
|
format: "org.matrix.custom.html",
|
2023-04-25 20:06:08 +00:00
|
|
|
formatted_body: html
|
|
|
|
}
|
|
|
|
}
|
2023-05-05 05:29:08 +00:00
|
|
|
|
2023-05-08 11:37:51 +00:00
|
|
|
module.exports.messageToEvent = messageToEvent
|