Repository: reactiflux/discord-irc (js)

Issue:
Sends empty message to IRC when an attachment is added
Not sure how robust discord.js is but when someone attaches a file of any format it will just send a blank message to IRC. It would be cool to pull the name of the attachment and put something like "<USER> Attached file 'filename.ext'." if that's not possible maybe just have it say something like "<USER> Attached a file, please log into Discord to view it."

Pull request description:
Send attachment URL to IRC
Also closes #14.

Patch:
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 5cfbf4e..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,5 +0,0 @@
-language: node_js
-node_js:
-  - '0.12'
-  - '4'
-  - '5'
diff --git a/lib/bot.js b/lib/bot.js
index 74f943e..aa24c73 100644
--- a/lib/bot.js
+++ b/lib/bot.js
@@ -143,6 +143,13 @@ class Bot {
         const prelude = `Command sent from Discord by ${username}:`;
         this.ircClient.say(ircChannel, prelude);
         this.ircClient.say(ircChannel, text);
+      } else if (message.attachments && message.attachments.length) {
+        message.attachments.forEach(a => {
+          const urlMessage =
+            `${coloredUsername} posted an attachment to ${channelName} on Discord: ${a.url}`;
+          logger.debug('Sending attachment URL to IRC', ircChannel, urlMessage);
+          this.ircClient.say(ircChannel, urlMessage);
+        });
       } else {
         text = `<${coloredUsername}> ${text}`;
         logger.debug('Sending message to IRC', ircChannel, text);


Test patch:
diff --git a/test/bot.test.js b/test/bot.test.js
index 3aadbe9..5707b03 100644
--- a/test/bot.test.js
+++ b/test/bot.test.js
@@ -84,6 +84,30 @@ describe('Bot', function() {
     ClientStub.prototype.say.should.have.been.calledWith('#irc', expected);
   });
 
+  it('should send attachment URL to IRC', function() {
+    const attachmentUrl = 'https://image/url.jpg';
+    const message = {
+      content: '',
+      attachments: [{
+        url: attachmentUrl
+      }],
+      mentions: [],
+      channel: {
+        name: 'discord'
+      },
+      author: {
+        username: 'otherauthor',
+        id: 'not bot id'
+      }
+    };
+
+    this.bot.sendToIRC(message);
+    // Wrap in colors:
+    const expected = `\u000304${message.author.username}\u000f posted an attachment to ` +
+      `#${message.channel.name} on Discord: ${attachmentUrl}`;
+    ClientStub.prototype.say.should.have.been.calledWith('#irc', expected);
+  });
+
   it('should not send its own messages to irc', function() {
     const message = {
       author: {