diff --git a/README.md b/README.md index eb38582..e1c49ac 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,8 @@ The container is locked down, so there is no networking, limited memory and CPU - `owner` - The owner(s) of the bot. Use an array for multiple owners. - `token` - The bot token. + - `prefix` - The prefix for commands. + - `codePrefix` - The prefix for code evaluation. - `languages` Languages to use. The language names here are different from the user-facing ones. Check the folders in `docker/` for the language names. diff --git a/config.example.json b/config.example.json index 0110d99..dc6ecac 100644 --- a/config.example.json +++ b/config.example.json @@ -1,6 +1,8 @@ { "owner": "12345678901234", "token": "MTU1fdsYNTRb2RT.FcD2l1ig.jIuKqwertyd432RROhF5A", + "prefix": ">", + "codePrefix": ">", "languages": [ "haskell", "python", diff --git a/src/listeners/messageInvalid.js b/src/listeners/messageInvalid.js index 332c4cd..8da7238 100644 --- a/src/listeners/messageInvalid.js +++ b/src/listeners/messageInvalid.js @@ -59,8 +59,9 @@ class MessageInvalidListener extends Listener { } parseMessage(message) { - const regex1 = /^\s*>\s*(.+?)?\s*```(.+?)\n([^]+)```\s*$/; - const regex2 = /^\s*>\s*(.+?)?\s*`(.+?) \s*([^]+)`\s*$/; + const prefix = this.client.config.codePrefix.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); + const regex1 = new RegExp(`^\\s*${prefix}\\s*(.+?)?\\s*\`\`\`(.+?)\\n([^]+)\`\`\`\\s*$`); + const regex2 = new RegExp(`^\\s*${prefix}\\s*(.+?)?\\s*\`(.+?) \\s*([^]+)\`\\s*$`); const match = message.content.match(regex1) || message.content.match(regex2); if (!match) { return null; diff --git a/src/struct/CompilerClient.js b/src/struct/CompilerClient.js index 36b4ed5..ed4a16b 100644 --- a/src/struct/CompilerClient.js +++ b/src/struct/CompilerClient.js @@ -13,7 +13,7 @@ class CompilerClient extends AkairoClient { this.commandHandler = new CommandHandler(this, { directory: path.join(__dirname, '../commands'), - prefix: '>', + prefix: config.prefix, allowMention: true, commandUtil: true, commandUtilLifetime: 3e5,