Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion gags/bast.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const garbleText = (text, parent, intensity) => {
let newtextparts = text.split(" ");
let outtext = "";
for (let i = 0; i < newtextparts.length; i++) {
if (Math.random() > 0.5 - 0.05 * intensity) {
if (Math.random() > 0.5 - 0.05 * intensity && !iscatnoise(newtextparts[i]) ) {
// 55-100% chance to replace

if (newtextparts[i].length < 3) {
Expand Down Expand Up @@ -57,5 +57,25 @@ function replacer(text, ogText, startWord, repeatWord, endWord) {
return text;
}

const catnoisepatterns = [
/nya+h/,
/meo+w/,
/pur+/,
/gr+/,
/mew/,
/mr+p/,
/mr+l/,
]
// Allows any of the above cat noises above at the beginning of the word, not case sensitive,
// followed by any sequence of ! ? . ~ <3
const fullcatnoisepatterns = catnoisepatterns.map(pattern => {
return new RegExp(`^${pattern.source}([!?.~]|<3)*$`, "i");
});
function iscatnoise(word) {
return fullcatnoisepatterns.some((pattern) => {
return word.match(pattern);
});
}

exports.garbleText = garbleText;
exports.choicename = "Bast Gag";