diff --git a/src/app.js b/src/app.js index d030ccb3..5ba2d1e6 100644 --- a/src/app.js +++ b/src/app.js @@ -344,26 +344,25 @@ class MautrixTelegram { const args = evt.content.body.substr(prefixLength) .split(" ") const command = args.shift() - commands.run(user, command, args, - (reply, { allowHTML = false, markdown = true } = {}) => { - reply = reply.replace("$cmdprefix", cmdprefix) - if (!markdown && !allowHTML) { - reply = escapeHTML(reply) - } - if (markdown) { - reply = marked(reply, { - sanitize: allowHTML, - }) - } - this.botIntent.sendMessage( + const replyFunc = (reply, { allowHTML = false, markdown = true } = {}) => { + reply = reply.replace("$cmdprefix", cmdprefix) + if (!markdown && !allowHTML) { + reply = escapeHTML(reply) + } + if (markdown) { + reply = marked(reply, { + sanitize: allowHTML, + }) + } + this.botIntent.sendMessage( evt.room_id, { body: sanitizeHTML(reply), formatted_body: reply, msgtype: "m.notice", format: "org.matrix.custom.html", }) - }, - this) + } + commands.run(user, command, args, replyFunc, this) return } diff --git a/src/commands.js b/src/commands.js index cf1a817c..6f81974a 100644 --- a/src/commands.js +++ b/src/commands.js @@ -174,7 +174,7 @@ commands.search = async (sender, args, reply, app) => { reply("Usage: $cmdprefix search [-r|--remote] ") return } - let msg = [] + const msg = [] if (args[0] !== "-r" && args[0] !== "--remote") { const contactResults = await sender.searchContacts(args.join(" ")) if (contactResults.length > 0) { diff --git a/src/telegram-peer.js b/src/telegram-peer.js index 2cee32f7..690138ed 100644 --- a/src/telegram-peer.js +++ b/src/telegram-peer.js @@ -90,8 +90,7 @@ class TelegramPeer { } async getInfo(telegramPOV) { - let info, - users + let info, users switch (this.type) { case "user": info = await telegramPOV.client("users.getFullUser", {