diff --git a/gags/bast.js b/gags/bast.js index cad4b11..4ee7d70 100644 --- a/gags/bast.js +++ b/gags/bast.js @@ -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) { @@ -29,7 +29,7 @@ const garbleText = (text, parent, intensity) => { outtext = `${outtext} `; } else { - outtext = `${outtext} ${newtextparts[i]}`; + outtext = `${outtext}${newtextparts[i]} `; } } return outtext; @@ -57,5 +57,26 @@ function replacer(text, ogText, startWord, repeatWord, endWord) { return text; } +const catnoisepatterns = [ + /nya+h?/, + /meo+w/, + /pur+/, + /gr+/, + /mew/, + /mrao/, + /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";