Commit b36dcab0 authored by Imran Hussain's avatar Imran Hussain

Fix bug where "target" would be highlighted inside of "targetword"

parent 2c9819b7
......@@ -92,8 +92,10 @@ function replace(targetWord, newWord, text) {
subTexts.forEach(function(element) {
// the regex checks the start of a word is either new line (^)
// or a word boundry (\b) whatever the fuck that means
// checks for word boundry (\b) or line end ($) at the end
// to stop parts of words being picked up when they shouldn't
// "gi" just says match every (g) and ignore case (i)
newSubTexts.push(element.replace(new RegExp("(^|\b)"+targetWord,"gi"),newWord));
newSubTexts.push(element.replace(new RegExp("(^|\b)"+targetWord+"($|\b)","gi"),newWord));
});
if (debugmode >= 2) {
mw.print("DEBUG: text after replace: " + newSubTexts);
......@@ -266,9 +268,9 @@ function handleEvent(event) {
// handle gsgs
if (mw.message_to == mw.whoami) {
//hide who gagged you
mw.print(newTimestamp + ": " + msg.text);
//mw.print(newTimestamp + ": " + msg.text);
//don't hide who gagged you
//mw.print(newTimestamp + "[" + msg.from_name + "]" + ": " + msg.text);
mw.print(newTimestamp + "[" + msg.from_name + "]" + ": " + msg.text);
} else {
mw.print(newTimestamp + "[" + msg.from_name + "]" + ": " + msg.text);
}
......@@ -283,9 +285,9 @@ function handleEvent(event) {
// handle kicking from the talker
if (mw.message_to == mw.whoami) {
//hide who zod'd you
mw.print(newTimestamp + ": " + msg.text);
//mw.print(newTimestamp + ": " + msg.text);
//don't hide who zod'd you
//mw.print(newTimestamp + "[" + msg.from_name + "]" + ": " + msg.text);
mw.print(newTimestamp + "[" + msg.from_name + "]" + ": " + msg.text);
} else {
mw.print(newTimestamp + "[" + msg.from_name + "]" + ": " + msg.text);
}
......@@ -294,9 +296,9 @@ function handleEvent(event) {
// handle kicking from the board
if (mw.message_to == mw.whoami) {
//hide who mrod'd you
mw.print(newTimestamp + ": " + msg.text);
//mw.print(newTimestamp + ": " + msg.text);
//don't hide who mrod'd you
//mw.print(newTimestamp + "[" + msg.from_name + "]" + ": " + msg.text);
mw.print(newTimestamp + "[" + msg.from_name + "]" + ": " + msg.text);
} else {
mw.print(newTimestamp + "[" + msg.from_name + "]" + ": " + msg.text);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment