<commit_before>var container = $('.message-pane');
var messageQueue = [];
var messageCount;
var textarea = $('#message-textarea');
var submit = $('input[type="submit"]');
var myUser = $('.chat-heading div').text().replace('Chat: ', '');
var gameStopped = true;

var respones = {};

function Question() {

    var a = Math.floor(100 * Math.random());
    var b = Math.floor(100 * Math.random());

    this.text = a + " + " + b + " = ?";
    this.answer = a + b;
}

$('.message', container).addClass('read');

var leaderboard = {};

function postMessage(message) {
    textarea.val("BOT: " + message);
    submit.trigger('click');
}

function processMessage() {
    if(messageQueue.length == 0) 
        return;

    // Don't do anything if the streamer is writing
    if(textarea.val() != '')
        return;

    var message = messageQueue.shift();

    // If it's an info message
    if(message.hasClass('message-info')) {       
        var text = message.text();
        
        // Someone entered the room
        if(text.indexOf(' joined the room.') != -1) {
            var userJoined = text.slice(0, text.indexOf(' joined the room.'));
            postMessage("Hello " + userJoined + " welcome to my stream!");
        }     
    } else {
        var userName = $('a', message).text();

        // Check command
        var command = message.clone().children().remove().end().text();
        var parameter = '';
        // See if the command has a parameter
        if(command.indexOf(' ') != -1) { 
            command = command.split(' ');

            parameter = command[1];
            command = command[0];
        }
           
        switch(command) {
            case '!help':
                postMessage('Available commands are !time, !leaderboard, !ans, !repo');
            break;

            case '!time':
                postMessage('@' + userName + ', the time is: ' + (new Date()).toLocaleTimeString());
            break;

            case '!leaderboard':
                var s = "No one answered correctly yet!";
                var max = -1;
                for(var user in leaderboard) {
                    if(max == -1 || leaderboard[user] > leaderboard[max]) {
                        max = user;
                    }
                }

                if(max != -1) {
                    s = "The leader is " + max + " with a score of " + leaderboard[max];
                }

                postMessage(s);               
            break;

            case '!ans':

                if(typeof question === 'undefined') {
                    postMessage("There is no unanswered question!");
                    break;
                }

                var answer = '';
                try {
                    answer = parseInt(parameter);
                } catch(err) {}

                if(answer == question.answer) {
                    if(leaderboard[userName] == undefined) {
                        leaderboard[userName] = 1;
                    } else {
                        leaderboard[userName]++;
                    }

                    postMessage('Congratulations ' + userName + '.' + answer + ' was the correct answer to ' + question.text);
                    question = undefined;
                }
            break;

            case '!repo':
                var repoName = respones.repo !== undefined ? respones.repo : 'not set :(';
                postMessage('@' + userName + ', the current repository is: ' + repoName);
            break;

            // Admin only commands
            case '!game':
                // Check if admin (bot has been started by the current user)
                if(userName != myUser) break;

                if(parameter == 'start') {<commit_msg>Change the username color to white while bot is talking<commit_after>var container = $('.message-pane');
var messageQueue = [];
var messageCount;
var textarea = $('#message-textarea');
var submit = $('input[type="submit"]');
var myUser = $('.chat-heading div').text().replace('Chat: ', '');
var gameStopped = true;
var botWritingCount = 0;

// Initiale the color pallete
$('#username-color').trigger('click');
$('#context-menu').trigger('mouseout');

var initialColor = $('#colorPremiumInput').val();

var respones = {};

function Question() {

    var a = Math.floor(100 * Math.random());
    var b = Math.floor(100 * Math.random());

    this.text = a + " + " + b + " = ?";
    this.answer = a + b;
}

$('.message', container).addClass('read');

var leaderboard = {};

function postMessage(message) {
    botWritingCount++;

    // Make name white
    $('.user-color-item').eq(0).attr('data-color', '#FFFFFF').trigger('click');
    setTimeout(function(){    
        textarea.val("BOT: " + message);
        submit.trigger('click');

        // Restore name color
        botWritingCount--;
        if(botWritingCount == 0) {
            setTimeout(function() {
                // Only change back the color if no message is being written
                if(botWritingCount == 0)
                $('.user-color-item').eq(0).attr('data-color', initialColor).trigger('click');
            }, 300);
        }
    }, 500);
}

function processMessage() {
    if(messageQueue.length == 0) 
        return;

    // Don't do anything if the streamer is writing
    if(textarea.val() != '')
        return;

    var message = messageQueue.shift();

    // If it's an info message
    if(message.hasClass('message-info')) {       
        var text = message.text();
        
        // Someone entered the room
        if(text.indexOf(' joined the room.') != -1) {
            var userJoined = text.slice(0, text.indexOf(' joined the room.'));
            postMessage("Hello " + userJoined + " welcome to my stream!");
        }     
    } else {
        var userName = $('a', message).text();

        // Check command
        var command = message.clone().children().remove().end().text();
        var parameter = '';
        // See if the command has a parameter
        if(command.indexOf(' ') != -1) { 
            command = command.split(' ');

            parameter = command[1];
            command = command[0];
        }
           
        switch(command) {
            case '!help':
                postMessage('Available commands are !time, !leaderboard, !ans, !repo');
            break;

            case '!time':
                postMessage('@' + userName + ', the time is: ' + (new Date()).toLocaleTimeString());
            break;

            case '!leaderboard':
                var s = "No one answered correctly yet!";
                var max = -1;
                for(var user in leaderboard) {
                    if(max == -1 || leaderboard[user] > leaderboard[max]) {
                        max = user;
                    }
                }

                if(max != -1) {
                    s = "The leader is " + max + " with a score of " + leaderboard[max];
                }

                postMessage(s);               
            break;

            case '!ans':

                if(typeof question === 'undefined') {
                    postMessage("There is no unanswered question!");
                    break;
                }

                var answer = '';
                try {
                    answer = parseInt(parameter);
                } catch(err) {}

                if(answer == question.answer) {
                    if(leaderboard[userName] == undefined) {
                        leaderboard[userName] = 1;
                    } else {
                        leaderboard[userName]++;
                    }

                    postMessage('Congratulations ' + userName + '. The correct answer was' + answer);
                    question = undefined;
                }
            break;

            case '!repo':
                var repoName = respones.repo !== undefined ? respones.repo : 'not set :(';
                postMessage('@' + userName + ', the current repository is: ' + repoName);
            break;

            // Admin only commands
            case '!game':
                // Check if admin (bot has been started by the current user)
                if(userName != myUser) break;

                if(parameter == 'start') {
{'fraction_non_alphanumeric': 0.14032747119466343, 'fraction_numerical': 0.005215281989084293, 'mean_word_length': 1.517094017094017, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4059478', 'n_tokens_mistral': 2238, 'n_tokens_neox': 2063, 'n_words': 560}