Allow disabling (prefixed) commands in non-management rooms

This commit is contained in:
Tulir Asokan
2017-11-27 18:42:00 +02:00
parent 486c7af6f7
commit a6bd561c7c
2 changed files with 4 additions and 3 deletions
+1
View File
@@ -29,6 +29,7 @@ bridge:
# Bridge management command configuration
commands:
# The prefix for all management commands.
# Can be removed to disable management commands in rooms with more than two users.
prefix: "!tg"
# Enables the !tg api ... commands for debugging.
+3 -3
View File
@@ -501,15 +501,15 @@ class MautrixTelegram {
}
}
const cmdprefix = this.config.bridge.commands.prefix
if (isManagement || evt.content.body.startsWith(`${cmdprefix} `)) {
if (isManagement || (cmdprefix && evt.content.body.startsWith(`${cmdprefix} `))) {
const prefixLength = cmdprefix.length + 1
if (evt.content.body.startsWith(`${cmdprefix} `)) {
if (cmdprefix && evt.content.body.startsWith(`${cmdprefix} `)) {
evt.content.body = evt.content.body.substr(prefixLength)
}
const args = evt.content.body.split(" ")
const command = args.shift()
const replyFunc = (reply, { allowHTML = false, markdown = true } = {}) => {
reply = reply.replace("$cmdprefix", cmdprefix)
reply = reply.replace("$cmdprefix", cmdprefix || "")
if (!markdown && !allowHTML) {
reply = escapeHTML(reply)
}