Allow disabling (prefixed) commands in non-management rooms
This commit is contained in:
@@ -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
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user