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
718 B
28 lines
718 B
let showdown = require('showdown');
|
|
|
|
let converter = new showdown.Converter();
|
|
|
|
enum MessageTypes {
|
|
TEXT = 'm.text',
|
|
NOTICE = 'm.notice'
|
|
}
|
|
|
|
function createBasicMessage(body: string, msgtype: MessageTypes = MessageTypes.TEXT) {
|
|
return {
|
|
"body": body,
|
|
"msgtype": msgtype
|
|
};
|
|
}
|
|
|
|
function createMarkdownMessage(body: string, markdown: string, msgtype: MessageTypes = MessageTypes.TEXT) {
|
|
return {
|
|
"body": body,
|
|
"msgtype": msgtype,
|
|
"format": "org.matrix.custom.html",
|
|
"formatted_body": converter.makeHtml(markdown)
|
|
};
|
|
}
|
|
|
|
export { MessageTypes as types };
|
|
export { createBasicMessage as createBasic };
|
|
export { createMarkdownMessage as createMarkdown };
|