function listener(bot) {
  return function(buffer) {
    var line = buffer.toString();
    var truncatedLine = line.slice(0,line.length-1);
    if (current_actions && !isNaN(parseInt(truncatedLine)) &&
        parseInt(truncatedLine) < current_actions.length) {
      var action = current_actions[parseInt(truncatedLine)];
      current_actions = null;
      if (typeof action === "string") {
        bot(platform, { sessionId: sessionId }, { type: 'action', message: action, action: action }, oncomplete);
      } else if (action.url) {
        request(action.url, function (error, response, body) {
          var article = unfluff(body);
          console.log(bot_name + ' > Processed Body For ' + article.title);
          console.log('\n'+article.text+'\n');
          oncomplete(null, null, null, function() {});
        });
      } else {
        bot(platform, { sessionId: sessionId }, { type: 'action', message: ''+action.payload, action: action.payload }, oncomplete);
      }
    } else {
      current_actions = null;
      bot(platform, { sessionId: sessionId }, { type: 'message', message: truncatedLine }, oncomplete);
    }
  };
}
function listener(bot) {
  return function(buffer) {
    var line = buffer.toString();
    var truncatedLine = line.slice(0,line.length-1);
    if (current_actions && !isNaN(parseInt(truncatedLine)) &&
        parseInt(truncatedLine) < current_actions.length) {
      var action = current_actions[parseInt(truncatedLine)];
      current_actions = null;
      if (typeof action === "string") {
        bot(platform, { sessionId: sessionId }, { type: 'action', message: action, action: action }, oncomplete);
      } else if (action.url) {
        request(action.url, function (error, response, body) {
          var article = unfluff(body);
          console.log(bot_name + ' > Processed Body For ' + article.title);
          console.log('\n'+article.text+'\n');
          oncomplete(null, null, null, function() {});
        });
      } else {
        bot(platform, { sessionId: sessionId }, { type: 'action', message: ''+action.payload, action: action.payload }, oncomplete);
      }
    } else {
      current_actions = null;
      bot(platform, { sessionId: sessionId }, { type: 'message', message: truncatedLine }, oncomplete);
    }
  };
}
function listener ( bot ) { return function ( buffer ) { var line = buffer . toString ( ) ; var truncatedLine = line . slice ( 0 , line . length - 1 ) ; if ( current_actions && ! isNaN ( parseInt ( truncatedLine ) ) && parseInt ( truncatedLine ) < current_actions . length ) { var action = current_actions [ parseInt ( truncatedLine ) ] ; current_actions = null ; if ( typeof action === "string" ) { bot ( platform , { sessionId : sessionId } , { type : 'action' , message : action , action : action } , oncomplete ) ; } else if ( action . url ) { request ( action . url , function ( error , response , body ) { var article = unfluff ( body ) ; console . log ( bot_name + ' > Processed Body For ' + article . title ) ; console . log ( '\n' + article . text + '\n' ) ; oncomplete ( null , null , null , function ( ) { } ) ; } ) ; } else { bot ( platform , { sessionId : sessionId } , { type : 'action' , message : '' + action . payload , action : action . payload } , oncomplete ) ; } } else { current_actions = null ; bot ( platform , { sessionId : sessionId } , { type : 'message' , message : truncatedLine } , oncomplete ) ; } } ; }
Define our stdin listener
Define our stdin listener