<commit_before>var wechatBot = require('wechat-bot');
var request = require('request');

var debug = require('debug')('wechat:letsface-api');
var _ = require('lodash');

/* include all apis */
exports = module.exports = function wechatLetsfaceApi(options) {
  options = exports.options(options);
  var bot = wechatBot();
  bot.use(exports.clubs(options));
  return bot;
};

/* fill options with default value */
exports.options = function (options) {
  return _.defaults({}, options, {url: 'http://localhost:3000'});
};

/* list clubs */
exports.clubs = function clubs(options) {
  options = exports.options(options);
  return function clubs(req, res, next) {
    var msg = req.weixin;
    if (msg.MsgType === 'text' && msg.Content.toLowerCase() === 'clubs') {
      request({
        uri: options.url + '/clubs/',
        json: true
      }, function requested(err, apiRes, body) {
        if (err) {
          return next(err);
        } else {
          debug('Get %d clubs', body.length);
          res.reply(body.length + ' clubs');
          return next();
        }
      });
    } else {
      return next();
    }
  };
};<commit_msg>Fix test error<commit_after>var wechatBot = require('wechat-bot');
var request = require('request');

var debug = require('debug')('wechat:letsface-api');
var _ = require('lodash');

/* include all apis */
exports = module.exports = function wechatLetsfaceApi(options) {
  options = exports.options(options);
  var bot = wechatBot();
  bot.use(exports.clubs(options));
  return bot;
};

/* fill options with default value */
exports.options = function (options) {
  return _.defaults({}, options, {url: 'http://localhost:3000'});
};

/* list clubs */
exports.clubs = function clubs(options) {
  options = exports.options(options);
  return function clubs(req, res, next) {
    var msg = req.weixin;
    if (msg.MsgType === 'text' && msg.Content.toLowerCase() === 'clubs') {
      request({
        uri: options.url + '/clubs/',
        json: true
      }, function requested(err, apiRes, body) {
        if (err) {
          return next(err);
        } else {
          debug('Get %d clubs', body.length);
          return res.reply(body.length + ' clubs');
        }
      });
    } else {
      return next();
    }
  };
};
{'fraction_non_alphanumeric': 0.16806352007057784, 'fraction_numerical': 0.0035288928098809, 'mean_word_length': 2.8835616438356166, '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': '2285864', 'n_tokens_mistral': 703, 'n_tokens_neox': 698, 'n_words': 171}