<commit_before>"use strict";

var Gitter = require("node-gitter");
var Vm = require("vm");
var DefaultConfig = require("./default-config");

/*
 * Class GitterBot.
 * @param {String} config.token token to gitter.im.
 * @param {String} config.gitterRoom name room gitter.im.
 */
var GitterBot = function(config) {
	config = config || {};
	this.token = config.token || DefaultConfig.token;
	this.gitterRoom = config.gitterRoom || DefaultConfig.gitterRoom;
};
/*
 * Starting the bot.
 */
GitterBot.prototype.run = function() {
	var gitter = new Gitter(this.token);
	gitter.rooms.join(this.gitterRoom)
		.then(this.onSuccessRoomJoin.bind(this))
		.fail(this.onFailRoomJoin.bind(this));
};
/*
 * Handler successfully joined the room.
 * @param {Object} room.
 */
GitterBot.prototype.onSuccessRoomJoin = function(room) {
	console.log("Joined room: ", room.name);
	room.listen().on("message", function(message) {
		this.processMessage(message, room);
	}.bind(this));
};
/*
 * Handler failure join the room.
 * @param {String} error.
 */
GitterBot.prototype.onFailRoomJoin = function(error) {
	console.log("Not possible to join this room: ", error);
};
/**
 * Returns the result of the expression.
 * @param {String} expression.
 * @returns {String} result.
 */
GitterBot.prototype.getResultOfExp = function(expression) {
	var result = Vm.runInNewContext(expression, {});
	return expression + "=" + result;
};
/**
 * Processes the message from Gitter
 * @param {Object} message.
 * @param {Object} room.
 */
GitterBot.prototype.processMessage = function(message, room) {
	if (message.text.match(/calc /) !== null) {
		var expression = message.text.replace(/[^\d\+\-\/\*\(\)]/g, "");
		if (expression !== "") {<commit_msg>test commit from storm<commit_after>"use strict";

var Gitter = require("node-gitter");
var Vm = require("vm");
var DefaultConfig = require("./default-config");

/*
 * Class GitterBot.
 * @param {String} config.token token to gitter.im.
 * @param {String} config.gitterRoom name room gitter.im.
 */
var GitterBot = function(config) {
	config = config || {};
	this.token = config.token || DefaultConfig.token;
	this.gitterRoom = config.gitterRoom || DefaultConfig.gitterRoom;
};
/*
 * Starting the bot.
 */
GitterBot.prototype.run = function() {
	var gitter = new Gitter(this.token);
	gitter.rooms.join(this.gitterRoom)
		.then(this.onSuccessRoomJoin.bind(this))
		.fail(this.onFailRoomJoin.bind(this));
};
/*
 * Handler successfully joined the room.
 * @param {Object} room.
 */
GitterBot.prototype.onSuccessRoomJoin = function(room) {
	console.log("Joined room: ", room.name);
	room.listen().on("message: ", function(message) {
		this.processMessage(message, room);
	}.bind(this));
};
/*
 * Handler failure join the room.
 * @param {String} error.
 */
GitterBot.prototype.onFailRoomJoin = function(error) {
	console.log("Not possible to join this room: ", error);
};
/**
 * Returns the result of the expression.
 * @param {String} expression.
 * @returns {String} result.
 */
GitterBot.prototype.getResultOfExp = function(expression) {
	var result = Vm.runInNewContext(expression, {});
	return expression + "=" + result;
};
/**
 * Processes the message from Gitter
 * @param {Object} message.
 * @param {Object} room.
 */
GitterBot.prototype.processMessage = function(message, room) {
	if (message.text.match(/calc /) !== null) {
		var expression = message.text.replace(/[^\d\+\-\/\*\(\)]/g, "");
		if (expression !== "") {
{'fraction_non_alphanumeric': 0.174279895257492, 'fraction_numerical': 0.0, 'mean_word_length': 4.297380585516179, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5785782', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1114, 'n_words': 253}