<commit_before>var tmi = require('tmi.js');
var emotes = require('./emotes.json');
var msg_count = 0; //the number of messages sent during the stream

class twitch_chat_reader {
    constructor(channel) {
        this.msg_count = 0;
        this.client = new tmi.client({
            options: {
                debug: false
            },
            connection: {
                cluster: "aws",
                reconnect: true
            },
            identity: {
                username: "lenny_face_bot",
                password: '<PASSWORD>'
            },
            channels: [channel]
        });
        this.wordDictionary = {};
        this.emojiDictionary = {};
    }

    getEmojiDictionary() {
        return emotes;
    }

    parse(user, msg) {
        msg_count++;
        var msg_arr = msg.split(" "); // split the message into array of string by whitespace
        var word_count = msg_arr.length; // get the count, this will be summed to the user's chattiness
        var caps_count = 0; //count of the number of CAPITALIZED words in the message, summed for user
        var emoji_count = 0; //count the number of emojis used, summed for user
        for (var i = 0; i < word_count; i++) {
            var word = msg_arr[i].trim();

            // Add the word to our word dicitonary
            // Be sure to remove dots to avoid dot notation in bracket notation
            let wordHashFriendly = word;
            wordHashFriendly = wordHashFriendly.replace(/\./g, '');
            wordHashFriendly = wordHashFriendly.replace(/\$/g, '');
            if(this.wordDictionary[wordHashFriendly]) {
              this.wordDictionary[wordHashFriendly]++;
            } else {
              this.wordDictionary[wordHashFriendly] = 1;
            }

            // Start our emjoi dictionary
            var emojiDict = this.getEmojiDictionary();
            // Check if it is an emoji
            if(emojiDict[word]) {
              if (this.emojiDictionary[word] != undefined) {
                  emoji_count++;
                  this.emojiDictionary[word]++;
              } else {
                emoji_count++;
                this.emojiDictionary[word] = 1;
              }
            }
            if (word === word.toUpperCase()) {
                //console.log(word+" "+word.toUpperCase());
                caps_count++;
            }
        }
        const response = {
          msg_count,
          word_count,
          caps_count,
          wordDictionary: this.wordDictionary,
          emojiDictionary: this.emojiDictionary
          //emoji_count - No Emoji Count until we get this working
        }
        return response;
    }

    run(chatCallback, context) {
        this.client.connect();

        this.client.on('chat', (channel, user, message) => {
            var user_string = user["username"];
            var message_return = user_string + " " + message;
            chatCallback(user_string, message_return, this.parse(user_string, message_return), context);
        });
    }
};

// Export the thing
module.exports = twitch_chat_reader;<commit_msg>Added color storing<commit_after>var tmi = require('tmi.js');
var emotes = require('./emotes.json');
var msg_count = 0; //the number of messages sent during the stream

class twitch_chat_reader {
    constructor(channel) {
        this.msg_count = 0;
        this.client = new tmi.client({
            options: {
                debug: false
            },
            connection: {
                cluster: "aws",
                reconnect: true
            },
            identity: {
                username: "lenny_face_bot",
                password: '<PASSWORD>'
            },
            channels: [channel]
        });
        this.wordDictionary = {};
        this.emojiDictionary = {};
        this.colorDictionary = {};3
    }

    getEmojiDictionary() {
        return emotes;
    }

    parse(user, msg, color) {
        msg_count++;
        var msg_arr = msg.split(" "); // split the message into array of string by whitespace
        var word_count = msg_arr.length; // get the count, this will be summed to the user's chattiness
        var caps_count = 0; //count of the number of CAPITALIZED words in the message, summed for user
        var emoji_count = 0; //count the number of emojis used, summed for user
        var color_count = 0; //counts user's most common color 

        for (var i = 0; i < word_count; i++) {
            var word = msg_arr[i].trim();

            // Add the word to our word dicitonary
            // Be sure to remove dots to avoid dot notation in bracket notation
            let wordHashFriendly = word;
            wordHashFriendly = wordHashFriendly.replace(/\./g, '');
            wordHashFriendly = wordHashFriendly.replace(/\$/g, '');
            if(this.wordDictionary[wordHashFriendly]) {
              this.wordDictionary[wordHashFriendly]++;
            } else {
              this.wordDictionary[wordHashFriendly] = 1;
            }

            //Adding in colors into the dict
            if(this.colorDictionary[color]){
                this.colorDictionary[color]++;
            } else {
                this.colorDictionary[color] = 1;
            }

            // Start our emjoi dictionary
            var emojiDict = this.getEmojiDictionary();
            // Check if it is an emoji
            if(emojiDict[word]) {
              if (this.emojiDictionary[word] != undefined) {
                  emoji_count++;
                  this.emojiDictionary[word]++;
              } else {
                emoji_count++;
                this.emojiDictionary[word] = 1;
              }
            }
            if (word === word.toUpperCase()) {
                //console.log(word+" "+word.toUpperCase());
                caps_count++;
            }
        }
        const response = {
          msg_count,
          word_count,
          caps_count,
          wordDictionary: this.wordDictionary,
          emojiDictionary: this.emojiDictionary,
          //emoji_count - No Emoji Count until we get this working
          colorDictionary: this.colorDictionary
        }
        return response;
    }

    run(chatCallback, context) {
        this.client.connect();

        this.client.on('chat', (channel, user, message) => {
            var user_string = user["username"];
            var user_color = user['color'];
            var message_return =  message;
            chatCallback(user_string, message_return, this.parse(user_string, message_return, user_color), context);
        });
    }
};

// Export the thing
module.exports = twitch_chat_reader;
{'fraction_non_alphanumeric': 0.10368246302444914, 'fraction_numerical': 0.002565650467853909, 'mean_word_length': 1.6423444976076556, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5889628', 'n_tokens_mistral': 1805, 'n_tokens_neox': 1737, 'n_words': 460}