diff --git a/package.json b/package.json index 82e8725659b312fed1f981c073df3510d6905ba1..c81a8f6713654ef3cf713635ea6e11bf5e632332 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "bluebird": "^3.4.7", "discord.js": "^11.0.0", "js-yaml": "^3.8.1", + "marked": "^0.3.6", "mime": "^1.3.4", "npmlog": "^4.0.2", "tslint": "^4.4.2", diff --git a/src/discordbot.ts b/src/discordbot.ts index 9240fe49ec07af243918bb57d12f97f9e9b71c08..bb286be380df3623311b62e262fd846f0ce150a1 100644 --- a/src/discordbot.ts +++ b/src/discordbot.ts @@ -4,6 +4,7 @@ import * as log from "npmlog"; import { MatrixUser, RemoteUser } from "matrix-appservice-bridge"; import { Util } from "./util"; import * as mime from "mime"; +import * as marked from "marked"; export class DiscordBot { private config: DiscordBridgeConfig; @@ -192,7 +193,19 @@ export class DiscordBot { }); }); if (msg.content !== null && msg.content !== "") { - intent.sendText(room, msg.content); + const markdown = marked(msg.content); + if (markdown !== msg.content) { + // Markdown message + intent.sendMessage(room, { + body: msg.content, + msgtype: "m.text", + formatted_body: markdown, + format: "org.matrix.custom.html", + }) + } else { + // Plain text + intent.sendText(room, msg.content); + } } }); }