'use strict';

const request = require('request');

module.exports = slackmentionbot;

const requestOptions = {
    method: 'POST',
    json: true,
    headers: {
        "content-type": "application/json"
    }
};

function slackmentionbot(slackWebhook, comment) {
    console.log('Slackbot comment: ', comment);
    request.post(slackWebhook, {
        form:{
            payload: buildPayload(comment)
        }
    }, function(err, response){
        if (response.body === 'ok') {
            console.log('Notification sent it!');
        }
    })
}

function buildPayload(comment) {

    return JSON.stringify({
        pretext: `Someone needs you help!  <${comment.html_url}|Click here>`,
        icon_emoji: ':ghost:',
        color:'#D00000',
        fields:[
            {
               title:'Mention',
               value: comment.body,
               short:false
            }
         ]

    })
}

@@ -622,18 +622,23 @@
     
-pre
 text: %60
+%3C@here%3E 
 Some
@@ -650,16 +650,17 @@
 eeds you
+r
  help!  
@@ -684,18 +684,28 @@
 rl%7D%7C
-Click here
+%3C$%7Bcomment.html_url%7D
 %3E%60,%0A
@@ -730,12 +730,13 @@
 : ':
-ghos
+parro
 t:',
@@ -761,23 +761,31 @@
 00000',%0A
+%0A
     
-   
+%7D);%0A    //
  fields:
@@ -790,21 +790,18 @@
 s:%5B%0A    
-     
+//
    %7B%0A   
@@ -797,30 +797,26 @@
  //   %7B%0A    
-      
+//
      title:'
@@ -829,27 +829,23 @@
 n',%0A    
-    
+//
      
-  
 value: c
@@ -861,27 +861,23 @@
 dy,%0A    
-  
+//
      
-    
 short:fa
@@ -884,21 +884,18 @@
 lse%0A    
-     
+//
    %7D%0A   
@@ -899,21 +899,11 @@
     
-     %5D%0A%0A    %7D)
+// %5D
 %0A%7D%0A

Update (slackmentionbot) message incoming slack