<commit_before>
var commands = require('./load_cmd_dir')
var config = require('../config')
var log = require('tablog')

// Glue logic between a raw slack message and a format that the commands
// expect. This function reads every message and attempts to find a command
// which it can match against. If it finds a match, it invokes that function.
module.exports = function(slackMsg, writeback) {

  // Check to make sure the message is not from jarvis
  if (slackMsg.user === require('../config')._jarvisUserId) {
    return
  }

  // If we have channels whitelisted, decline the message if it isnt from that channel
  if (config.whitelist_channels) {
    var inn = false
    config.whitelist_channels.forEach(function(channel) {
      if (channel === slackMsg.channel) {
        inn = true
      }
    })
    if (!inn) {
      log.info("Received message on non-whitelisted channel, not responding.")
      return
    }
  }

  // If we have channels blacklisted, ignore the message from that channel
  if (config.blacklist_channels) {
    config.blacklist_channels.forEach(function(channel) {
      if (channel === slackMsg.channel) {
        log.info("Received message on blacklisted channel, not responding.")
        return
      }
    })
  }

  // If the first word of the message is jarvis, lowercase it
  // This is just a convenience thing so we dont have to write
  // matching regex for both upper and lower case just to support
  // the autocapitalization feature on most smartphones
  if (slackMsg.text.split(' ')[0] === "Jarvis") {
    slackMsg.text = 'j' + slackMsg.text.slice(1)
  }

  commands.forEach(function(command) {<commit_msg>Fixed bug with channel blacklisting<commit_after>
var commands = require('./load_cmd_dir')
var config = require('../config')
var log = require('tablog')

// Glue logic between a raw slack message and a format that the commands
// expect. This function reads every message and attempts to find a command
// which it can match against. If it finds a match, it invokes that function.
module.exports = function(slackMsg, writeback) {

  // Check to make sure the message is not from jarvis
  if (slackMsg.user === require('../config')._jarvisUserId) {
    return
  }

  // If we have channels whitelisted, decline the message if it isnt from that channel
  if (config.whitelist_channels) {
    var inn = false
    config.whitelist_channels.forEach(function(channel) {
      if (channel === slackMsg.channel) {
        inn = true
      }
    })
    if (!inn) {
      log.info("Received message on non-whitelisted channel, not responding.")
      return
    }
  }

  // If we have channels blacklisted, ignore the message from that channel
  if (config.blacklist_channels) {
    var inn = false
    config.blacklist_channels.forEach(function(channel) {
      if (channel === slackMsg.channel) {
        inn = true
      }
    })
    if (inn) {
      log.info("Received message on blacklisted channel, not responding.")
      return
    }
  }

  // If the first word of the message is jarvis, lowercase it
  // This is just a convenience thing so we dont have to write
  // matching regex for both upper and lower case just to support
  // the autocapitalization feature on most smartphones
  if (slackMsg.text.split(' ')[0] === "Jarvis") {
    slackMsg.text = 'j' + slackMsg.text.slice(1)
  }

  commands.forEach(function(command) {
{'fraction_non_alphanumeric': 0.1007705986959099, 'fraction_numerical': 0.0011855364552459987, 'mean_word_length': 3.037081339712919, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '721845', 'n_tokens_mistral': 972, 'n_tokens_neox': 952, 'n_words': 359}