Baphomet is the dedicated bot for nulloctet matrix
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.

27 lines
718 B

  1. let showdown = require('showdown');
  2. let converter = new showdown.Converter();
  3. enum MessageTypes {
  4. TEXT = 'm.text',
  5. NOTICE = 'm.notice'
  6. }
  7. function createBasicMessage(body: string, msgtype: MessageTypes = MessageTypes.TEXT) {
  8. return {
  9. "body": body,
  10. "msgtype": msgtype
  11. };
  12. }
  13. function createMarkdownMessage(body: string, markdown: string, msgtype: MessageTypes = MessageTypes.TEXT) {
  14. return {
  15. "body": body,
  16. "msgtype": msgtype,
  17. "format": "org.matrix.custom.html",
  18. "formatted_body": converter.makeHtml(markdown)
  19. };
  20. }
  21. export { MessageTypes as types };
  22. export { createBasicMessage as createBasic };
  23. export { createMarkdownMessage as createMarkdown };