<commit_before>var request = require('request');
var _ = require('lodash');
var async = require('async');
var config = require('./config.json');
var slack = require('./slack');


module.exports = function (req, res, next) {
  var gitbot = config.slack.bot || { name : 'gitbot', icon_emoji : ':octocat:' };

  if (!gitbot.channel) {
    gitbot.channel = req.body.channel_id || '';
  }

  var directive = req.body.text && req.body.text.replace(req.body.trigger_word, '');

  var flags = {
    all : false,
  }

  switch (true) {
    case /all/.test(directive):
      flags.all = true;
      break;

    case /(.\S+)\/(.\S+)/.test(directive):
      flags.single = directive.trim();
      break;

    default:
      break;
  }

  var username = config.github.username;
  var token = config.github.token;
  var teams = config.github.teams;

  async.map(teams, iterator, function (error, results) {
    if (error) { return next(error); }

    // make attachments if incoming hook tokens have been provided
    if (res.locals.slackTokens) {
      gitbot.text = '*PULL REQUESTS*';
      gitbot.attachments = [];

      _.each(results, function (group, i) {
        gitbot.attachments.push(makeAttachment(group, flags));
      });
<commit_msg>add todos<commit_after>var request = require('request');
var _ = require('lodash');
var async = require('async');
var config = require('./config.json');
var slack = require('./slack');


module.exports = function (req, res, next) {
  var gitbot = config.slack.bot || { name : 'gitbot', icon_emoji : ':octocat:' };

  if (!gitbot.channel) {
    gitbot.channel = req.body.channel_id || '';
  }

  var directive = req.body.text && req.body.text.replace(req.body.trigger_word, '');

  var flags = {
    all : false,
  }

  switch (true) {
    case /all/.test(directive):
      flags.all = true;
      break;

    case /(.\S+)\/(.\S+)/.test(directive):
      // todo: enable ability to query single repo
      flags.single = directive.trim();
      break;

    case /help/.test(directive):
      // todo: send user suggestions

    default:
      break;
  }

  var username = config.github.username;
  var token = config.github.token;
  var teams = config.github.teams;

  async.map(teams, iterator, function (error, results) {
    if (error) { return next(error); }

    // make attachments if incoming hook tokens have been provided
    if (res.locals.slackTokens) {
      gitbot.text = '*PULL REQUESTS*';
      gitbot.attachments = [];

      _.each(results, function (group, i) {
        gitbot.attachments.push(makeAttachment(group, flags));
      });

{'fraction_non_alphanumeric': 0.16163959783449341, 'fraction_numerical': 0.0, 'mean_word_length': 2.866965620328849, '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': '292231', 'n_tokens_mistral': 861, 'n_tokens_neox': 825, 'n_words': 196}