<commit_before>// ==UserScript==
// @name         RohBot Nicknames
// @version      1.2
// @description  Allows the user set custom nicknames to other users
// @author       Spans
// @match        https://rohbot.net
// @grant        none
// @updateURL	 https://raw.githubusercontent.com/Spanfile/RohBot-Nicknames/master/nicknames.js
// ==/UserScript==
/* jshint -W097 */
'use strict';

var storeKey = "spans-nicknames";
var nicknames = {}; // id: { nick, original }

function loadNicks() {
	nicknames = JSON.parse(RohStore.get(storeKey) || "{}");
}

function saveNicks() {
	RohStore.set(storeKey, JSON.stringify(nicknames));
}

function unescape(str) {
	return $('<textarea/>').html(str).text();
}

cmd.register("nick", "--]", function (chat, args) {
	if (args.length != 3 || args[0].length === 0 || args[1].length === 0 || args[2].length === 0) {
		chat.statusMessage("Usage: /nick (id|name) nickname user");
		return;
	}
	
	var user;
	if (args[0] == "id") {
		user = chat.userList.find(function (user) { return user.UserId == args[2]; });
	} else if (args[0] == "name") {
		user = chat.userList.find(function (user) { return unescape(user.Name) == args[2]; });
	}
	
	if (!user) {
		chat.statusMessage("Who's " + args[2] + "?");
		return;
	}
	
	nicknames[user.UserId] = { nick: args[1], original: user.Name };
	chat.statusMessage(user.Name + " is now " + args[1] + "!");
	
	saveNicks();
});

cmd.register("removenick", "-]", function (chat, args) {
	if (args.length != 2 || args[0].length === 0 || args[0].length === 0) {
		chat.statusMessage("Usage: /removenick (id|name) nickname|id");
		return;
	}
	
	var user;
	if (args[0] == "id") {
		user = chat.userList.find(function (user) { return user.UserId == args[1]; });
	} else if (args[0] == "name") {
		user = chat.userList.find(function (user) { return unescape(user.Name) == args[1]; });
	}
	
	if (!user) {
		chat.statusMessage("Who's " + args[1] + "?");
		return;
	}
	<commit_msg>Fixed slight issue with name/id check<commit_after>// ==UserScript==
// @name         RohBot Nicknames
// @version      1.2.1
// @description  Allows the user set custom nicknames to other users
// @author       Spans
// @match        https://rohbot.net
// @grant        none
// @updateURL	 https://raw.githubusercontent.com/Spanfile/RohBot-Nicknames/master/nicknames.js
// ==/UserScript==
/* jshint -W097 */
'use strict';

var storeKey = "spans-nicknames";
var nicknames = {}; // id: { nick, original }

function loadNicks() {
	nicknames = JSON.parse(RohStore.get(storeKey) || "{}");
}

function saveNicks() {
	RohStore.set(storeKey, JSON.stringify(nicknames));
}

function unescape(str) {
	return $('<textarea/>').html(str).text();
}

cmd.register("nick", "--]", function (chat, args) {
	if (args.length != 3 || args[0].length === 0 || args[1].length === 0 || args[2].length === 0) {
		chat.statusMessage("Usage: /nick (id|name) nickname user");
		return;
	}
	
	var user;
	if (args[0] == "id") {
		user = chat.userList.find(function (user) { return user.UserId == args[2]; });
	} else if (args[0] == "name") {
		user = chat.userList.find(function (user) { return unescape(user.Name) == args[2]; });
	} else {
		chat.statusMessage("Usage: /nick (id|name) nickname user");
		return;
	}
	
	if (!user) {
		chat.statusMessage("Who's " + args[2] + "?");
		return;
	}
	
	nicknames[user.UserId] = { nick: args[1], original: user.Name };
	chat.statusMessage(user.Name + " is now " + args[1] + "!");
	
	saveNicks();
});

cmd.register("removenick", "-]", function (chat, args) {
	if (args.length != 2 || args[0].length === 0 || args[0].length === 0) {
		chat.statusMessage("Usage: /removenick (id|name) nickname|id");
		return;
	}
	
	var user;
	if (args[0] == "id") {
		user = chat.userList.find(function (user) { return user.UserId == args[1]; });
	} else if (args[0] == "name") {
		user = chat.userList.find(function (user) { return unescape(user.Name) == args[1]; });
	} else {
		chat.statusMessage("Usage: /nick (id|name) nickname user");
		return;
	}
	
	if (!user) {
		chat.statusMessage("Who's " + args[1] + "?");
		return;
	}
	
{'fraction_non_alphanumeric': 0.21280788177339902, 'fraction_numerical': 0.014532019704433498, 'mean_word_length': 3.5938914027149322, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, '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': '2426847', 'n_tokens_mistral': 1542, 'n_tokens_neox': 1462, 'n_words': 313}