diff --git a/lib/bot.js b/lib/bot.js index b05ef160..a9e5e3cf 100644 --- a/lib/bot.js +++ b/lib/bot.js @@ -299,7 +299,21 @@ class Bot { } isCommandMessage(message) { - return this.commandCharacters.some(prefix => message.startsWith(prefix)); + return this.commandCharacters.some(prefix => + typeof prefix == 'string' + ? message.startsWith(prefix) + : message.startsWith(prefix[0]) + ); + } + + getCommandPrefix(message) { + if (this.isCommandMessage(message)) { + let command = this.commandCharacters.filter(x => typeof x == 'object' && message.startsWith(x[0])) + if (command.length > 0) { + return command[0] + } + } + return ['', ''] } ignoredIrcUser(user) { @@ -369,7 +383,8 @@ class Bot { const prelude = Bot.substitutePattern(this.formatCommandPrelude, patternMap); this.ircClient.say(ircChannel, prelude); } - this.ircClient.say(ircChannel, text); + let command = this.getCommandPrefix(text) + this.ircClient.say(ircChannel, text.replace(command[0], command[1])); } else { if (text !== '') { // Convert formatting