Improve management command output and add user link pills to search output (ref #7)

This commit is contained in:
Tulir Asokan
2017-11-25 15:06:02 +02:00
parent 69db7c8192
commit 77a2705dd9
3 changed files with 61 additions and 31 deletions
+13 -4
View File
@@ -98,8 +98,15 @@ class MautrixTelegram {
* @returns {Intent} The Matrix puppet intent for the given Telegram user.
*/
getIntentForTelegramUser(id) {
return this.bridge.getIntentFromLocalpart(
this.config.bridge.username_template.replace("${ID}", id))
return this.bridge.getIntentFromLocalpart(this.getUsernameForTelegramUser(id))
}
getUsernameForTelegramUser(id) {
return this.config.bridge.username_template.replace("${ID}", id)
}
getMatrixToLinkForTelegramUser(id) {
return `https://matrix.to/#/@${this.getUsernameForTelegramUser(id)}:${this.config.homeserver.domain}`
}
/**
@@ -340,11 +347,13 @@ class MautrixTelegram {
commands.run(user, command, args,
(reply, { allowHTML = false, markdown = true } = {}) => {
reply = reply.replace("$cmdprefix", cmdprefix)
if (!allowHTML) {
if (!markdown && !allowHTML) {
reply = escapeHTML(reply)
}
if (markdown) {
reply = marked(reply)
reply = marked(reply, {
sanitize: allowHTML,
})
}
this.botIntent.sendMessage(
evt.room_id, {