<commit_before>'use strict';
var util = require( 'util' ),
    defaultConfig = {
        response: 'Tack %s! Nu blir det dunkadunka!',
        initMix: 'Kokarn: Lägg in dagens mix!',
        channel: '#kokarn',
        addCommand: '!addmix',
        sayCommand: '!mix'
    };

function configOption ( config, option ) {
    if ( option in config ) {
        return config[ option ];
    }
    return defaultConfig[ option ];
}

function today () {
    var now = new Date();
    return now - ( now % 86400000 );
}

function DagensMix ( config ) {
    if ( !config ) {
        config = {};
    }
    this.mixes = [];

    this.initMix = configOption( config, 'initMix' );
    this.channel = configOption( config, 'channel' );
    this.addCommand = configOption( config, 'addCommand' );
    this.sayCommand = configOption( config, 'sayCommand' );
    this.response = configOption( config, 'response' );

    this.resetTimer = 0;
    this.addMix(this.initMix);

    this.dayMixAdded = today();

    // start reset timeouts
    this.reset();
}

DagensMix.prototype.reset = function() {
    var instance = this;

    if ( this.dayMixAdded < today() ) {
        this.addMix( this.initMix );
    }

    this.resetTimer = setTimeout( function () {
        instance.reset();
    }, 300000 );
};

DagensMix.prototype.addBot = function( bot ) {
    this.bot = bot;

    var instance = this;
    // say mix
    this.addListener( function ( from, text, message ) {
        if ( text === instance.sayCommand ) {
            instance.say();
        }
    });

    // add mix
    this.addListener( function ( from, text, message ) {
        if ( text.indexOf( instance.addCommand ) === 0 ) {
            var mix = text.substring( instance.addCommand.length );
            instance.add( mix, from );
        }
    });
};

DagensMix.prototype.addMix = function ( mix ) {
    this.mixes.push( mix );
    this.currentMix = mix;
};
<commit_msg>Fixed mix not resetting at midnight<commit_after>'use strict';
var util = require( 'util' ),
    defaultConfig = {
        response: 'Tack %s! Nu blir det dunkadunka!',
        initMix: 'Kokarn: Lägg in dagens mix!',
        channel: '#kokarn',
        addCommand: '!addmix',
        sayCommand: '!mix'
    };

function configOption ( config, option ) {
    if ( option in config ) {
        return config[ option ];
    }
    return defaultConfig[ option ];
}

function today () {
    var now = new Date();
    return now - ( now % 86400000 );
}

function DagensMix ( config ) {
    if ( !config ) {
        config = {};
    }
    this.mixes = [];

    this.initMix = configOption( config, 'initMix' );
    this.channel = configOption( config, 'channel' );
    this.addCommand = configOption( config, 'addCommand' );
    this.sayCommand = configOption( config, 'sayCommand' );
    this.response = configOption( config, 'response' );

    this.resetTimer = 0;
    this.addMix(this.initMix);

    // start reset timeouts
    this.reset();
}

DagensMix.prototype.reset = function() {
    var instance = this;

    if ( this.dayMixAdded < today() ) {
        this.addMix( this.initMix );
    }

    this.resetTimer = setTimeout( function () {
        instance.reset();
    }, 300000 );
};

DagensMix.prototype.addBot = function( bot ) {
    this.bot = bot;

    var instance = this;
    // say mix
    this.addListener( function ( from, text, message ) {
        if ( text === instance.sayCommand ) {
            instance.say();
        }
    });

    // add mix
    this.addListener( function ( from, text, message ) {
        if ( text.indexOf( instance.addCommand ) === 0 ) {
            var mix = text.substring( instance.addCommand.length );
            instance.add( mix, from );
        }
    });
};

DagensMix.prototype.addMix = function ( mix ) {
    this.mixes.push( mix );
    this.currentMix = mix;
    this.dayMixAdded = today();
};

{'fraction_non_alphanumeric': 0.14126778783958602, 'fraction_numerical': 0.008279430789133247, 'mean_word_length': 2.3071000855431993, 'pattern_counts': {'":': 0, '<': 5, '<?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': '855838', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1190, 'n_words': 295}