<commit_before>// Emoticons

var color = require('../color');
var emoticons = require('../emoticons');
var emotes = emoticons.emotes;
var emotesKeys = emoticons.emotesKeys;
var patternRegex = emoticons.patternRegex;

if (!CommandParser.originalParse) {
    CommandParser.originalParse = CommandParser.parse;
}

CommandParser.parse = function(message, room, user, connection, levelsDeep) {
    if (!room.allowEmoticons || (message.charAt(0) === '/' && message.charAt(1) !== '/')) {
        return CommandParser.originalParse(message, room, user, connection, levelsDeep + 1);
    }
    message = CommandParser.originalParse(message, room, user, connection, levelsDeep);
    if (!message) return message;

    var match = false;
    var len = emotesKeys.length;

    while (len--) {
        if (message.indexOf(emotesKeys[len]) >= 0) {
            match = true;
            break;
        }
    }

    if (!match) return message;

    // escape HTML
    message = Tools.escapeHTML(message);

    // emoticons
    message = message.replace(patternRegex, function(match) {
        var emote = emotes[match];
        return typeof emote === 'string' ? '<img src="' + emote + '" title="' + match + '" />' : match;
    });

    // __italics__
    message = message.replace(/\_\_([^< ](?:[^<]*?[^< ])?)\_\_(?![^<]*?<\/a)/g, '<i>$1</i>');

    // **bold**
    message = message.replace(/\*\*([^< ](?:[^<]*?[^< ])?)\*\*/g, '<b>$1</b>');

    room.addRaw(
        '<div class="chat"><small>' + user.getIdentity().charAt(0) + '</small>' +
        '<button name="parseCommand" value="/user ' + user.name + '" class="emote-chat">' +
        '<b><font color="' + color(user.userid) + '">' + user.name + ':</font></b></button>' +
        '<em class="mine">' + message + '</em></div>'
        );<commit_msg>Allow room ranks with emoticons<commit_after>// Emoticons

var color = require('../color');
var emoticons = require('../emoticons');
var emotes = emoticons.emotes;
var emotesKeys = emoticons.emotesKeys;
var patternRegex = emoticons.patternRegex;

if (!CommandParser.originalParse) {
    CommandParser.originalParse = CommandParser.parse;
}

CommandParser.parse = function(message, room, user, connection, levelsDeep) {
    if (!room.allowEmoticons || (message.charAt(0) === '/' && message.charAt(1) !== '/')) {
        return CommandParser.originalParse(message, room, user, connection, levelsDeep + 1);
    }
    message = CommandParser.originalParse(message, room, user, connection, levelsDeep);
    if (!message) return message;

    var match = false;
    var len = emotesKeys.length;

    while (len--) {
        if (message.indexOf(emotesKeys[len]) >= 0) {
            match = true;
            break;
        }
    }

    if (!match) return message;

    // escape HTML
    message = Tools.escapeHTML(message);

    // emoticons
    message = message.replace(patternRegex, function(match) {
        var emote = emotes[match];
        return typeof emote === 'string' ? '<img src="' + emote + '" title="' + match + '" />' : match;
    });

    // __italics__
    message = message.replace(/\_\_([^< ](?:[^<]*?[^< ])?)\_\_(?![^<]*?<\/a)/g, '<i>$1</i>');

    // **bold**
    message = message.replace(/\*\*([^< ](?:[^<]*?[^< ])?)\*\*/g, '<b>$1</b>');

    var group = user.getIdentity().charAt(0);
    if (room.auth) group = room.auth[user.userid] || user.getIdentity().charAt(0);

    room.addRaw(
        '<div class="chat"><small>' + group + '</small>' +
        '<button name="parseCommand" value="/user ' + user.name + '" class="emote-chat">' +
        '<b><font color="' + color(user.userid) + '">' + user.name + ':</font></b></button>' +
        '<em class="mine">' + message + '</em></div>'
        );
{'fraction_non_alphanumeric': 0.21361058601134217, 'fraction_numerical': 0.004050769646232784, 'mean_word_length': 3.0086580086580086, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 39, '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': '2869518', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1194, 'n_words': 244}