<commit_before>var express = require('express');
var app = express();
var moment = require('moment');

var port = process.env.PORT || 3000;
app.listen(port); // binding to a port just for heroku

if (process.env.NODE_ENV != "production") {
	require('dotenv').config();
}

var assignments = require("./assignments");

var readings = require("./readings");
var sessions = require("./sessions.js");

var controller = require('botkit').slackbot({
	debug: false,
	storage: require('botkit-storage-firebase')({
		firebase_uri: process.env.FIREBASE_URL
	})
});

controller.spawn({
	token: process.env.SLACK_BOT_API_TOKEN
}).startRTM(function(err) {
	if (err) {
		console.log(err);
		throw new Error('Could not connect to Slack');
	} else {
		console.log("Connected to Slack");
	}
});

controller.hears(['submit ([0-9]+)\s*(.*)'], ['direct_message'], function(bot, message) {
	var assignmentNumber = message.match[1];
	if (assignmentNumber > assignments.length - 1) {
		bot.reply(message, "Sorry! That assignment isn't available yet. See what assignments are available with `assignments`.");
	} else {
		var url = message.match[2].replace(/[<>]/g, "").trim();
		bot.reply(message, "Submitting " + url + " for Assignment #" + assignmentNumber + "...");
		assignments[parseInt(assignmentNumber)](url, function(err, scoreObject) {
			if (err) {
				bot.reply(message, "Error: " + err);
			} else {
				bot.startPrivateConversation(message, function(err, convo) {
					convo.say("Done processing. Your score is: " + (scoreObject.score * 100).toFixed(2) + "%");
					for (var test of scoreObject.tests) {
						convo.say((test.passed ? ":white_check_mark:" : ":x:") + " " + test.description);
					}
					// write score
					controller.storage.users.get(message.user, function(err, user_data) {
						if (!user_data) {
							user_data = {
								id: message.user
							};
						}
						if (!("id" in user_data)) {
							user_data.id = message.user;
						}
						if (!("assignments" in user_data)) {<commit_msg>changing test results to expandable attachment<commit_after>var express = require('express');
var app = express();
var moment = require('moment');

var port = process.env.PORT || 3000;
app.listen(port); // binding to a port just for heroku

if (process.env.NODE_ENV != "production") {
	require('dotenv').config();
}

var assignments = require("./assignments");

var readings = require("./readings");
var sessions = require("./sessions.js");

var controller = require('botkit').slackbot({
	debug: false,
	storage: require('botkit-storage-firebase')({
		firebase_uri: process.env.FIREBASE_URL
	})
});

controller.spawn({
	token: process.env.SLACK_BOT_API_TOKEN
}).startRTM(function(err) {
	if (err) {
		console.log(err); // eslint-disable-line no-console
		throw new Error('Could not connect to Slack');
	} else {
		console.log("Connected to Slack"); // eslint-disable-line no-console
	}
});

controller.hears(['submit ([0-9]+)\s*(.*)'], ['direct_message'], function(bot, message) {
	var assignmentNumber = message.match[1];
	if (assignmentNumber > assignments.length - 1) {
		bot.reply(message, "Sorry! That assignment isn't available yet. See what assignments are available with `assignments`.");
	} else {
		var url = message.match[2].replace(/[<>]/g, "").trim();
		bot.reply(message, "Submitting " + url + " for Assignment #" + assignmentNumber + "...");
		bot.reply(message, "Processing " + url + " _(this may take a few moments)_");
		assignments[parseInt(assignmentNumber)](url, function(err, scoreObject) {
			if (err) {
				bot.reply(message, "Error: " + err);
			} else {
				bot.startPrivateConversation(message, function(err, convo) {
					convo.say("Done processing. Your score is: " + (scoreObject.score * 100).toFixed(2) + "%");
					var tests = [];
					for (var test of scoreObject.tests) {
						tests.push((test.passed ? ":white_check_mark:" : ":x:") + " " + test.description);
					}
					convo.say({
						attachments: [{
							fallback: "Test results for assignment " + assignmentNumber + ": " + url,
							text: tests.join("\n"),
							mrkdwn_in: ["text"]
						}]
					});
					// write score
					controller.storage.users.get(message.user, function(err, user_data) {
						if (!user_data) {
							user_data = {
								id: message.user
							};
						}
						if (!("id" in user_data)) {
							user_data.id = message.user;
						}
						if (!("assignments" in user_data)) {
{'fraction_non_alphanumeric': 0.17419940949352714, 'fraction_numerical': 0.0059050647285941405, 'mean_word_length': 3.66031746031746, 'pattern_counts': {'":': 5, '<': 5, '<?xml version=': 0, '>': 7, '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': '1106743', 'n_tokens_mistral': 1666, 'n_tokens_neox': 1412, 'n_words': 325}