<commit_before>const Docker = require('dockerode');
const concatStream = require('concat-stream');
const {RTM_EVENTS: {MESSAGE}} = require('@slack/client');
const cloudinary = require('cloudinary');

const docker = new Docker();

class TimeoutError extends Error { }

module.exports = (clients) => {
	const {rtmClient: rtm, webClient: slack} = clients;

	rtm.on(MESSAGE, async (message) => {
		if (message.channel !== process.env.CHANNEL_SANDBOX) {
			return;
		}

		if (message.subtype !== undefined) {
			return;
		}

		if (!message.text || !message.text.match(/^[\d\w\s()+\-*/!^'":<>,$=#.%]+$/)) {
			return;
		}

		let stdoutWriter = null;

		const stdoutPromise = new Promise((resolve) => {
			stdoutWriter = concatStream({encoding: 'buffer'}, (stdout) => {
				resolve(stdout);
			});
		});

		let stderrWriter = null;

		const stderrPromise = new Promise((resolve) => {
			stderrWriter = concatStream({encoding: 'buffer'}, (stderr) => {
				resolve(stderr);
			});
		});

		let container = null;

		const executeContainer = async () => {
			container = await docker.createContainer({
				Hostname: '',
				User: '',<commit_msg>Trigger computation by `[` and `]`<commit_after>const Docker = require('dockerode');
const concatStream = require('concat-stream');
const {RTM_EVENTS: {MESSAGE}} = require('@slack/client');
const cloudinary = require('cloudinary');

const docker = new Docker();

class TimeoutError extends Error { }

module.exports = (clients) => {
	const {rtmClient: rtm, webClient: slack} = clients;

	rtm.on(MESSAGE, async (message) => {
		if (message.channel !== process.env.CHANNEL_SANDBOX) {
			return;
		}

		if (message.subtype !== undefined) {
			return;
		}

		if (!message.text || !message.text.match(/^[\d\w\s()+\-*/!^'":<>,$=#.%[\]]+$/)) {
			return;
		}

		let stdoutWriter = null;

		const stdoutPromise = new Promise((resolve) => {
			stdoutWriter = concatStream({encoding: 'buffer'}, (stdout) => {
				resolve(stdout);
			});
		});

		let stderrWriter = null;

		const stderrPromise = new Promise((resolve) => {
			stderrWriter = concatStream({encoding: 'buffer'}, (stderr) => {
				resolve(stderr);
			});
		});

		let container = null;

		const executeContainer = async () => {
			container = await docker.createContainer({
				Hostname: '',
				User: '',
{'fraction_non_alphanumeric': 0.1863001745200698, 'fraction_numerical': 0.0, 'mean_word_length': 3.9311827956989247, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 19, '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': '292405', 'n_tokens_mistral': 856, 'n_tokens_neox': 731, 'n_words': 162}