You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
653 B
28 lines
653 B
let showdown = require('showdown');
|
|
|
|
let converter = new showdown.Converter();
|
|
|
|
let messageTypes = {
|
|
TEXT: 'm.text',
|
|
NOTICE: 'm.notice'
|
|
}
|
|
|
|
function createBasicMessage(body, msgtype = messageTypes.TEXT) {
|
|
return {
|
|
"body": body,
|
|
"msgtype": msgtype
|
|
};
|
|
}
|
|
|
|
function createMarkdownMessage(body, markdown, msgtype = messageTypes.TEXT) {
|
|
return {
|
|
"body": body,
|
|
"msgtype": msgtype,
|
|
"format": "org.matrix.custom.html",
|
|
"formatted_body": converter.makeHtml(markdown)
|
|
};
|
|
}
|
|
|
|
exports.types = messageTypes;
|
|
exports.createBasic = createBasicMessage;
|
|
exports.createMarkdown = createMarkdownMessage;
|