<commit_before>var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);

var messages = [];

app.get('/', function(req, res){
  res.sendFile(__dirname + '/index.html');
});

function filterMessage(message){
	return  {id: message.id, txt: message.txt, yesVotes: message.yesVotes.length, noVotes: message.noVotes.length};
}

io.on('connection', function(socket){
  var filteredMessages = [];  
  var allowed = false;
  setInterval(function () {
		allowed = true;
	  }, 5000); 
  for(var i in messages){
	  filteredMessages.push(filterMessage(messages[i]));
  }
  socket.emit('messages', filteredMessages);
	
  socket.on('chat message', function(msg){
    if(!allowed){
		socket.emit('myError','Stop spamming me bro');
		return;
	}
	if(!msg || typeof msg != 'string' || msg.trim().length === 0){
	 	socket.emit('myError', 'Speak up');
	   return;
	}
	  
	  var message = {id: messages.length, txt: msg.trim(), yesVotes: [], noVotes: []};
	 allowed = false;
	 messages.push(message);
	 setInterval(function () {
		allowed = true;
	  }, 5000); 
	io.emit('chat message', filterMessage(message));
  });
  socket.on('vote', function(vote){<commit_msg>Function<commit_after>var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);

var messages = [];

app.get('/', function(req, res){
  res.sendFile(__dirname + '/index.html');
});

function filterMessage(message){
	return  {id: message.id, txt: message.txt, yesVotes: message.yesVotes.length, noVotes: message.noVotes.length};
}

io.on('connection', function(socket){
  var filteredMessages = [];  
  var allowed = false;
  setInterval(function () {
		allowed = true;
	  }, 5000); 
  for(var i in messages){
	  filteredMessages.push(filterMessage(messages[i]));
  }
  socket.emit('messages', filteredMessages);
	
  socket.on('chat message', function(msg){
    if(!allowed){
		socket.emit('myError','Stop spamming me bro');
		return;
	}
	if(!msg || typeof msg != 'string' || msg.trim().length() === 0){
	 	socket.emit('myError', 'Speak up');
	   return;
	}
	  
	  var message = {id: messages.length, txt: msg.trim(), yesVotes: [], noVotes: []};
	 allowed = false;
	 messages.push(message);
	 setInterval(function () {
		allowed = true;
	  }, 5000); 
	io.emit('chat message', filterMessage(message));
  });
  socket.on('vote', function(vote){
{'fraction_non_alphanumeric': 0.19019689987431923, 'fraction_numerical': 0.00754084625052367, 'mean_word_length': 4.489655172413793, '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': '4236904', 'n_tokens_mistral': 826, 'n_tokens_neox': 767, 'n_words': 167}