<commit_before>import os from 'os';
import { wit } from '../index';
import moment from 'moment-timezone';
import { randomInt } from '../../lib/botResponses';
import http from 'http';
import bodyParser from 'body-parser';

// END OF A WORK SESSION
export default function(controller) {

	/**
	 * 		INDEX functions of work sessions
	 */
	
	/**
	 * 		FINISHING A WORK SESSION BY COMMAND
	 */
	
	// we are relying on wit to do all of the NL parsing for us
	// so that it normalizes into `intent` strings for us to decipher
	controller.hears(['done_session'], 'direct_message', wit.hears, (bot, message) => {

		// when done with session
		// 1. Great work {name}!
		// 2. What would you like to remember about this session? This could be something specific about what you got done, or more general notes about how you felt
		// 3. Awesome :) Which tasks did you complete? I'll update your list
		// 4. show task list
		// 5. get numbers to then cross out task list. CROSS TASK LIST BY EDITING MESSAGE
		// 6. Lastly, how did that session feel? (put the 4 emojis)
		// 7. Would you like to take a break? Or just respond to what user says
		

		// this clears the timeout that you set
		clearTimeout(bot.timer);
		

		bot.api.reactions.add({
			timestamp: message.ts,
			channel: message.channel,
			name: 'star',
		}, (err, res) => {
			console.log("added reaction!");
			console.log(res);
			if (err) {
				bot.botkit.log('Failed to add emoji reaction :(', err);
			}
		});

		bot.send({
        type: "typing",
        channel: message.channel
    });
    setTimeout(()=>{
    	bot.startConversation(message, askForReflection);
    }, randomInt(1000, 1750));

	});


};


/**
 * 		CONVERSATION QUESTIONS
 * 		these are callback functions that take 2 params
 * 		1) response (that specific response)
 * 		2) convo (object of entire convo)
 */

function askForReflection(response, convo) {
	console.log("asking for reflection");

	const { task }                = convo;
	const { bot, source_message } = task;

	convo.say("Excellent work!! :sports_medal:");

	convo.ask("What would you like to remember about this session? This could be something specific about what you got done, or more general notes about how you felt", (response, convo) => {

		// reward the reflection!
		const { task: { bot, convos } }     = convo;
		const { responses: { reflection } } = convos[0];
		
		bot.api.reactions.add({
			timestamp: reflection.ts,
			channel: reflection.channel,
			name: '100',
		}, (err, res) => {
			console.log("added reaction!");
			console.log(res);
			if (err) {
				bot.botkit.log('Failed to add emoji reaction :(', err);
			}
		});
		
		askForTaskUpdate(response, convo);
		convo.next();

	}, { 'key' : 'reflection' });

	convo.on('end', finishReflection);

}

function askForTaskUpdate(response, convo) {

	const { task }                = convo;
	const { bot, source_message } = task;

	bot.send({
		type: "typing",
		channel: source_message.channel
	});

	convo.say("Awesome stuff!! Great to hear :smiley:");
	convo.ask("Which tasks did you complete? I’ll update your list :pencil: (i.e `1, 5, 4`)", (response, convo) => {
		askForBreak(response, convo);
		convo.next();
	}, { 'key': 'tasksDone' });
	
}

function askForBreak(response, convo) {

	const { task }                = convo;
	const { bot, source_message } = task;

	convo.say("Excellent!");
	convo.ask("Would you like to take a 15 minute break now before jumping in to your next focused session?", [
			{
				pattern: bot.utterances.yes,
				callback: (response, convo) => {
					convo.say("Sounds great! I'll ping you in 15 minutes :timer_clock:");
			  	convo.next();
				}
			},
			{
				pattern: bot.utterances.no,
				callback: (response, convo) => {
				  convo.say("Sounds good. I'll be here when you're ready to jump back in :swimmer:");
				  convo.next();
				}
			},
			{
				default: true,
				callback: function(response, convo) {
					convo.say("Sorry, I didn't get that :dog:");
				  convo.repeat();
				  convo.next();
				}
			}
	], { 'key' : 'wantsBreak' });
}

function finishReflection(convo) {

	const { task }                = convo;
	const { bot, source_message } = task;

	if (convo.status == 'completed') {

		// all of user responses in object
		var res = convo.extractResponses();

		var reflection = convo.extractResponse('reflection');
		convo.say(`Nice. Your reflection was: ${reflection}`);

		console.log("FINISH REFLECTION");
		console.log(bot);
		console.log(JSON.stringify(bot.storage));
		console.log('\n\n\n\n\n\n\n\n\n\n\n');
		console.log(JSON.stringify(convo));

	} else {
		// this happens if the conversation ended prematurely for some reason
		convo.say(message, 'Okay, nevermind then!');
	}
}<commit_msg>Take out stringify convo<commit_after>import os from 'os';
import { wit } from '../index';
import moment from 'moment-timezone';
import { randomInt } from '../../lib/botResponses';
import http from 'http';
import bodyParser from 'body-parser';

// END OF A WORK SESSION
export default function(controller) {

	/**
	 * 		INDEX functions of work sessions
	 */
	
	/**
	 * 		FINISHING A WORK SESSION BY COMMAND
	 */
	
	// we are relying on wit to do all of the NL parsing for us
	// so that it normalizes into `intent` strings for us to decipher
	controller.hears(['done_session'], 'direct_message', wit.hears, (bot, message) => {

		// when done with session
		// 1. Great work {name}!
		// 2. What would you like to remember about this session? This could be something specific about what you got done, or more general notes about how you felt
		// 3. Awesome :) Which tasks did you complete? I'll update your list
		// 4. show task list
		// 5. get numbers to then cross out task list. CROSS TASK LIST BY EDITING MESSAGE
		// 6. Lastly, how did that session feel? (put the 4 emojis)
		// 7. Would you like to take a break? Or just respond to what user says
		

		// this clears the timeout that you set
		clearTimeout(bot.timer);
		

		bot.api.reactions.add({
			timestamp: message.ts,
			channel: message.channel,
			name: 'star',
		}, (err, res) => {
			console.log("added reaction!");
			console.log(res);
			if (err) {
				bot.botkit.log('Failed to add emoji reaction :(', err);
			}
		});

		bot.send({
        type: "typing",
        channel: message.channel
    });
    setTimeout(()=>{
    	bot.startConversation(message, askForReflection);
    }, randomInt(1000, 1750));

	});


};


/**
 * 		CONVERSATION QUESTIONS
 * 		these are callback functions that take 2 params
 * 		1) response (that specific response)
 * 		2) convo (object of entire convo)
 */

function askForReflection(response, convo) {
	console.log("asking for reflection");

	const { task }                = convo;
	const { bot, source_message } = task;

	convo.say("Excellent work!! :sports_medal:");

	convo.ask("What would you like to remember about this session? This could be something specific about what you got done, or more general notes about how you felt", (response, convo) => {

		// reward the reflection!
		const { task: { bot, convos } }     = convo;
		const { responses: { reflection } } = convos[0];
		
		bot.api.reactions.add({
			timestamp: reflection.ts,
			channel: reflection.channel,
			name: '100',
		}, (err, res) => {
			console.log("added reaction!");
			console.log(res);
			if (err) {
				bot.botkit.log('Failed to add emoji reaction :(', err);
			}
		});
		
		askForTaskUpdate(response, convo);
		convo.next();

	}, { 'key' : 'reflection' });

	convo.on('end', finishReflection);

}

function askForTaskUpdate(response, convo) {

	const { task }                = convo;
	const { bot, source_message } = task;

	bot.send({
		type: "typing",
		channel: source_message.channel
	});

	convo.say("Awesome stuff!! Great to hear :smiley:");
	convo.ask("Which tasks did you complete? I’ll update your list :pencil: (i.e `1, 5, 4`)", (response, convo) => {
		askForBreak(response, convo);
		convo.next();
	}, { 'key': 'tasksDone' });
	
}

function askForBreak(response, convo) {

	const { task }                = convo;
	const { bot, source_message } = task;

	convo.say("Excellent!");
	convo.ask("Would you like to take a 15 minute break now before jumping in to your next focused session?", [
			{
				pattern: bot.utterances.yes,
				callback: (response, convo) => {
					convo.say("Sounds great! I'll ping you in 15 minutes :timer_clock:");
			  	convo.next();
				}
			},
			{
				pattern: bot.utterances.no,
				callback: (response, convo) => {
				  convo.say("Sounds good. I'll be here when you're ready to jump back in :swimmer:");
				  convo.next();
				}
			},
			{
				default: true,
				callback: function(response, convo) {
					convo.say("Sorry, I didn't get that :dog:");
				  convo.repeat();
				  convo.next();
				}
			}
	], { 'key' : 'wantsBreak' });
}

function finishReflection(convo) {

	const { task }                = convo;
	const { bot, source_message } = task;

	if (convo.status == 'completed') {

		// all of user responses in object
		var res = convo.extractResponses();

		var reflection = convo.extractResponse('reflection');
		convo.say(`Nice. Your reflection was: ${reflection}`);

		console.log("FINISH REFLECTION");
		console.log(bot);
		console.log(JSON.stringify(bot.storage));
		console.log('\n\n\n\n\n\n\n\n\n\n\n');
		console.log(convo);

	} else {
		// this happens if the conversation ended prematurely for some reason
		convo.say(message, 'Okay, nevermind then!');
	}
}
{'fraction_non_alphanumeric': 0.1414023549379442, 'fraction_numerical': 0.006364697146494113, 'mean_word_length': 3.0550537634408603, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5521313', 'n_tokens_mistral': 3496, 'n_tokens_neox': 3010, 'n_words': 959}