<commit_before>'use strict';

const request = require('request');
const merge = require('lodash.merge');

function Command(data, token, opts) {
	const actions = [];
	const helpEntries = [];
	const options = merge({
		delay: {
			force: false,
			force_response: {
				response_type: 'ephemeral',
				text: 'Got it'
			}
		}
	}, opts);

	function checkToken() {
		if(!token) {
			console.warn('Without a validation token anyone can execute your command.');
		} else {
			if(data.token !== token) throw 'Invalid token';
		}
	}

	function getHelpText() {
		return {
			response_type: 'ephemeral',
			text: helpEntries.reverse().map(entry => `• ${data.command} ${entry}`).join('\n')
		};
	}

	function action(pattern, help, handler) {
		if(typeof pattern !== RegExp) {
			pattern = new RegExp(pattern);
		}

		actions.push({pattern, handler});
		helpEntries.push(help);
		
		return this;
	}

	function finish(callback) {
		return function (err, result) {<commit_msg>Parse data from application/x-www-form-urlencoded query string<commit_after>'use strict';

const request = require('request');
const merge = require('lodash.merge');
const qs = require('qs');

function Command(rawData, token, opts) {
	const actions = [];
	const helpEntries = [];
	const options = merge({
		delay: {
			force: false,
			force_response: {
				response_type: 'ephemeral',
				text: 'Got it!'
			}
		}
	}, opts);

	let data = {};
	if(typeof data === 'string') {
		data = qs.parse(rawData);
	} else {
		data = rawData;
	}

	function checkToken() {
		if(!token) {
			console.warn('Without a validation token anyone can execute your command.');
		} else {
			if(data.token !== token) throw 'Invalid token';
		}
	}

	function getHelpText() {
		return {
			response_type: 'ephemeral',
			text: helpEntries.reverse().map(entry => `• ${data.command} ${entry}`).join('\n')
		};
	}

	function action(pattern, help, handler) {
		if(typeof pattern !== RegExp) {
			pattern = new RegExp(pattern);
		}

		actions.push({pattern, handler});
		helpEntries.push(help);
		
		return this;
	}

	function finish(callback) {
		return function (err, result) {
{'fraction_non_alphanumeric': 0.1605873993368072, 'fraction_numerical': 0.0, 'mean_word_length': 3.7674943566591423, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '3256842', 'n_tokens_mistral': 776, 'n_tokens_neox': 684, 'n_words': 174}