<commit_before>var JSONSaver = require("../jsonsaver");

var QuoteServer = module.exports = function(filename) {
    this.filename = filename;
    this.changed = false;
    this.loaded = false;
    this.db = new JSONSaver(filename);
};

QuoteServer.prototype.save = function(nick, quote) {
    if (this.db.object.quotes.nick) {
        this.db.object.quotes.nick.push(quote);
    }
    else {
        this.db.object.quotes[nick] = [quote];
    }
    this.db.activity();
};

QuoteServer.prototype.random = function(nick) {
    var nick_quotes = this.db.object.quotes[nick];
    var random_number = Math.floor(Math.random() * nick_quotes.length);
    return nick_quotes[random_number];
};<commit_msg>Fixed multiple quotes and added toLowerCase<commit_after>var JSONSaver = require("../jsonsaver");

var QuoteServer = module.exports = function(filename) {
    this.filename = filename;
    this.changed = false;
    this.loaded = false;
    this.db = new JSONSaver(filename);
};

QuoteServer.prototype.save = function(nick, quote) {
    nick = nick.toLowerCase();
    if (this.db.object.quotes[nick]) {
        this.db.object.quotes[nick].push(quote);
    }
    else {
        this.db.object.quotes[nick] = [quote];
    }
    this.db.activity();
};

QuoteServer.prototype.random = function(nick) {
    nick = nick.toLowerCase();
    var nick_quotes = this.db.object.quotes[nick];
    var random_number = Math.floor(Math.random() * nick_quotes.length);
    return nick_quotes[random_number];
};
{'fraction_non_alphanumeric': 0.14630872483221477, 'fraction_numerical': 0.0, 'mean_word_length': 3.4375, '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': '7449627', 'n_tokens_mistral': 489, 'n_tokens_neox': 489, 'n_words': 83}