<commit_before>/// <reference path=".vscode/node.d.ts" />

var ircLib = require('irc');
var moment = require('moment');
require('moment-precise-range-plugin');
var fs = require('fs');

var userFile = './irc-hectate/users.json';
var userData = {};
var msgFile = './irc-hectate/messages.json';
var msgData = {};
var tarotFile = "./irc-hectate/json/tarot.json";
var tarotData = {};
var wordGameFile = './irc-hectate/json/word_clues.json';
var wordGameData = {};
var guessGameActive = false;
var guessWord = "";
var guessGameTimer = 300000; //5 minutes in milliseconds
var guessGameTimeout;

var endTime = new Date("May 9, 2016 21:00:00");
var event1 = "LD35 judging ends in";
var event2 = ".";
var echoMode = false;
var echoAdmin = "Hectate";
var botName = "JinxBot";
var channel = "#stencyl";

//Local Launch config requires a couple of alterations to some variables.
//The starting path is different, so we point to the files where they are,
//and we change the bot's name, since JinxBot is probably running in-channel right now as well.
if (process.argv[2] == "l") {
	console.log("Local Launch detected, starting with alternate config.")
	userFile = 'users.json';
	msgFile = 'messages.json';
	tarotFile = './json/tarot.json';
	wordGameFile = './json/word_clues.json';
	botName = "LocalBot";
}

var saveFreq = 600000; //10 minutes in milliseconds
var msgFreq = 60000; //1 minute in milliseconds
var coffeeList = ["a mug of black coffee","a shot of espresso","a foamy cappuccino","a big latte","a sweetened mocha","a little cup of Turkish coffee","a macchiato with caramel","a strong Irish coffee"," a well-chilled, iced coffee"];


//read the data file for users
fs.readFile(userFile, function (err, data) {
	if(err) throw err;
	userData = JSON.parse(data);
	console.log("User data loaded.");
});

//read the data file for messages
fs.readFile(msgFile, function (err, data) {
	if(err) {  console.log(err); throw err; }
	msgData = JSON.parse(data);
	console.log("Message data loaded.");
	//console.log(msgData);
});

//read the data file for tarot descriptions
fs.readFile(tarotFile, function (err,data) {
	if(err) { console.log(err); throw err; }
	tarotData = JSON.parse(data);
	console.log("Tarot data loaded.");
});

//read the data file for word guess game
fs.readFile(wordGameFile, function (err,data) {
	if(err) { console.log(err); throw err; }
	wordGameData = JSON.parse(data);
	console.log("Word game data loaded.");
})


var client = new ircLib.Client('irc.esper.net', botName, {
	channels: [channel],
	floodProtection: true,
	autoRejoin: true,
});

var saveInterval = setInterval(saveData,saveFreq);
var msgInterval = setInterval(checkMessages,msgFreq);

//client.addListener('message', function (from, to, message) {
//	console.log(from + ' => ' + to + ': ' + message);
//});

client.addListener('quit', function(nick,reason,channel,message) {
	if(nick == echoAdmin) {
		echoMode = false;
		console.log("echoMode disabled due to echoAdmin quit detected by: " + echoAdmin);
	}
	return;
});

//logging of notices from server, etc.
client.addListener('notice', function(nick, to, text, message) {
	console.log("Notice: " + text);
	return;
});

//log messages said by users to users.json for the !seen command needs
client.addListener('message', function(nick, to, message){
	if(to == channel ) {
		var ts = moment();
		if(!nameExists(nick)) {
			userData.users.push(
				{
					"name":nick,
					"timestamp": ts,
				}
			)
		}
		else {
			userData.users[getName(nick)].timestamp = ts;
		}
	}
});

client.addListener('message', function (nick, to, text, message) {
	var arrText = text.split(" ");
	if (guessGameActive == true) {
		for (i in arrText) {
			if(arrText[i] == guessWord) {
				client.say(channel, nick + " just got the word! It was " + guessWord + "!");
				guessGameEnd(true);
				//TODO: award points here or something eventually...
			}
		}
	}
	if (arrText[0][0]!= '!')
		return;
	if (arrText[0]=="!seen") {
		if (arrText.length == 1) {
			client.say(to, "Who are you looking for, " + nick + "?");
			return;
		}
		var handle = arrText[1];
		if(handle == nick) {
			client.say(to, "But " + handle + ", you're right here with me!");
			return;
		}
		if(handle == botName) {
			client.say(to, "You're talking to me!");
			return;
		}
		if(!nameExists(handle)) {
			client.say(to, "I don't remember seeing " + handle + "."	);
			return;
		}
		else {
			var diff = moment.preciseDiff(userData.users[getName(handle)].timestamp,moment());
			client.say(to, handle + " was last seen talking " + diff + " ago.");
			return;
		}<commit_msg>Added plural checks for !guessgame<commit_after>/// <reference path=".vscode/node.d.ts" />

var ircLib = require('irc');
var moment = require('moment');
require('moment-precise-range-plugin');
var fs = require('fs');

var userFile = './irc-hectate/users.json';
var userData = {};
var msgFile = './irc-hectate/messages.json';
var msgData = {};
var tarotFile = "./irc-hectate/json/tarot.json";
var tarotData = {};
var wordGameFile = './irc-hectate/json/word_clues.json';
var wordGameData = {};
var guessGameActive = false;
var guessWord = "";
var guessGameTimer = 300000; //5 minutes in milliseconds
var guessGameTimeout;

var endTime = new Date("May 9, 2016 21:00:00");
var event1 = "LD35 judging ends in";
var event2 = ".";
var echoMode = false;
var echoAdmin = "Hectate";
var botName = "JinxBot";
var channel = "#stencyl";

//Local Launch config requires a couple of alterations to some variables.
//The starting path is different, so we point to the files where they are,
//and we change the bot's name, since JinxBot is probably running in-channel right now as well.
if (process.argv[2] == "l") {
	console.log("Local Launch detected, starting with alternate config.")
	userFile = 'users.json';
	msgFile = 'messages.json';
	tarotFile = './json/tarot.json';
	wordGameFile = './json/word_clues.json';
	botName = "LocalBot";
}

var saveFreq = 600000; //10 minutes in milliseconds
var msgFreq = 60000; //1 minute in milliseconds
var coffeeList = ["a mug of black coffee","a shot of espresso","a foamy cappuccino","a big latte","a sweetened mocha","a little cup of Turkish coffee","a macchiato with caramel","a strong Irish coffee"," a well-chilled, iced coffee"];


//read the data file for users
fs.readFile(userFile, function (err, data) {
	if(err) throw err;
	userData = JSON.parse(data);
	console.log("User data loaded.");
});

//read the data file for messages
fs.readFile(msgFile, function (err, data) {
	if(err) {  console.log(err); throw err; }
	msgData = JSON.parse(data);
	console.log("Message data loaded.");
	//console.log(msgData);
});

//read the data file for tarot descriptions
fs.readFile(tarotFile, function (err,data) {
	if(err) { console.log(err); throw err; }
	tarotData = JSON.parse(data);
	console.log("Tarot data loaded.");
});

//read the data file for word guess game
fs.readFile(wordGameFile, function (err,data) {
	if(err) { console.log(err); throw err; }
	wordGameData = JSON.parse(data);
	console.log("Word game data loaded.");
})


var client = new ircLib.Client('irc.esper.net', botName, {
	channels: [channel],
	floodProtection: true,
	autoRejoin: true,
});

var saveInterval = setInterval(saveData,saveFreq);
var msgInterval = setInterval(checkMessages,msgFreq);

//client.addListener('message', function (from, to, message) {
//	console.log(from + ' => ' + to + ': ' + message);
//});

client.addListener('quit', function(nick,reason,channel,message) {
	if(nick == echoAdmin) {
		echoMode = false;
		console.log("echoMode disabled due to echoAdmin quit detected by: " + echoAdmin);
	}
	return;
});

//logging of notices from server, etc.
client.addListener('notice', function(nick, to, text, message) {
	console.log("Notice: " + text);
	return;
});

//log messages said by users to users.json for the !seen command needs
client.addListener('message', function(nick, to, message){
	if(to == channel ) {
		var ts = moment();
		if(!nameExists(nick)) {
			userData.users.push(
				{
					"name":nick,
					"timestamp": ts,
				}
			)
		}
		else {
			userData.users[getName(nick)].timestamp = ts;
		}
	}
});

client.addListener('message', function (nick, to, text, message) {
	var arrText = text.split(" ");
	if (guessGameActive == true) {
		for (i in arrText) {
			if(arrText[i] == guessWord || (arrText[i] == (guessWord + 's'))) {
				client.say(channel, nick + " just got the word! It was " + guessWord + "!");
				guessGameEnd(true);	
				//TODO: award points here or something eventually...
			}
		}
	}
	if (arrText[0][0]!= '!')
		return;
	if (arrText[0]=="!seen") {
		if (arrText.length == 1) {
			client.say(to, "Who are you looking for, " + nick + "?");
			return;
		}
		var handle = arrText[1];
		if(handle == nick) {
			client.say(to, "But " + handle + ", you're right here with me!");
			return;
		}
		if(handle == botName) {
			client.say(to, "You're talking to me!");
			return;
		}
		if(!nameExists(handle)) {
			client.say(to, "I don't remember seeing " + handle + "."	);
			return;
		}
		else {
			var diff = moment.preciseDiff(userData.users[getName(handle)].timestamp,moment());
			client.say(to, handle + " was last seen talking " + diff + " ago.");
			return;
		}
{'fraction_non_alphanumeric': 0.16457492087744188, 'fraction_numerical': 0.009167303284950344, 'mean_word_length': 4.062983425414365, 'pattern_counts': {'":': 4, '<': 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': '286242', 'n_tokens_mistral': 3339, 'n_tokens_neox': 3069, 'n_words': 879}