Repository: reactiflux/discord-irc (js)

Issue:
Multicharacter command characters
I put
```json
"commandCharacters": ["@@", "$"]
```
in my config, and it works fine for the prefix $ but not the prefix @@, as it's more than one character. I know it's a rare case but I'm using 2 characters as the input character for my bot, shouldn't be too hard to fix.

Pull request:
Closes #299
(With help from @ekmartin :P I cannot JavaScript)

Patch:
diff --git a/lib/bot.js b/lib/bot.js
index 2587178..619ebcb 100644
--- a/lib/bot.js
+++ b/lib/bot.js
@@ -248,7 +248,7 @@ class Bot {
   }
 
   isCommandMessage(message) {
-    return this.commandCharacters.indexOf(message[0]) !== -1;
+    return this.commandCharacters.some(prefix => message.startsWith(prefix));
   }
 
   static substitutePattern(message, patternMapping) {


Test patch:
diff --git a/test/bot.test.js b/test/bot.test.js
index 23c9610..293fdde 100644
--- a/test/bot.test.js
+++ b/test/bot.test.js
@@ -480,6 +480,30 @@ describe('Bot', function () {
     ClientStub.prototype.say.getCall(1).args.should.deep.equal(['#irc', text]);
   });
 
+  it('should support multi-character command prefixes', function () {
+    const bot = new Bot({ ...config, commandCharacters: ['@@'] });
+    const text = '@@test command';
+    const message = {
+      content: text,
+      mentions: { users: [] },
+      channel: {
+        name: 'discord'
+      },
+      author: {
+        username: 'test',
+        id: 'not bot id'
+      },
+      guild: this.guild
+    };
+    bot.connect();
+
+    bot.sendToIRC(message);
+    ClientStub.prototype.say.getCall(0).args.should.deep.equal([
+      '#irc', 'Command sent from Discord by test:'
+    ]);
+    ClientStub.prototype.say.getCall(1).args.should.deep.equal(['#irc', text]);
+  });
+
   it('should hide usernames for commands to Discord', function () {
     const username = 'ircuser';
     const text = '!command';