<commit_before>var express = require('express');
var router = express.Router();
var flip = require('flip');
var request = require('request');
var util = require('./util');
var tokens = process.env.SLACK_TOKENS;
var webhook = process.env.SLACK_WEBHOOK_URL;

// authenticate requests
router.use(function (req, res, next) {
  if (req.body.token !== tokens) {
    return res.status(401).send({ success: false, error: 'Invalid token.' });
  }
  next();
});

// set channel override
router.use(function (req, res, next) {
  if (req.body.channel_name === 'directmessage' || req.body.channel_name === 'privategroup') {
    req.channel = req.body.channel_id;
  } else {
    req.channel = '#' + req.body.channel_name;
  }
  next();
});

// tableflip command<commit_msg>allow multiple tokens to be set in env var<commit_after>var express = require('express');
var router = express.Router();
var flip = require('flip');
var request = require('request');
var tokens = process.env.SLACK_TOKENS.split(',');
var webhook = process.env.SLACK_WEBHOOK_URL;

// authenticate requests
router.use(function (req, res, next) {
  if (tokens.indexOf(req.body.token) == -1) {
    return res.status(401).send({ success: false, error: 'Invalid token.' });
  }
  next();
});

// set channel override
router.use(function (req, res, next) {
  if (req.body.channel_name === 'directmessage' || req.body.channel_name === 'privategroup') {
    req.channel = req.body.channel_id;
  } else {
    req.channel = '#' + req.body.channel_name;
  }
  next();
});

// tableflip command
{'fraction_non_alphanumeric': 0.17478882391163092, 'fraction_numerical': 0.004548408057179987, 'mean_word_length': 4.202702702702703, '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': '2292917', 'n_tokens_mistral': 513, 'n_tokens_neox': 500, 'n_words': 120}