From c8fce4748ce98556d76b83cd881283608f8bc9f7 Mon Sep 17 00:00:00 2001 From: Caleb Fontenot Date: Tue, 4 Apr 2023 12:00:08 -0500 Subject: [PATCH 1/3] update abbreviation_key.json --- abbreviation_key.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abbreviation_key.json b/abbreviation_key.json index a0fff7d..fd2b4be 100644 --- a/abbreviation_key.json +++ b/abbreviation_key.json @@ -1 +1 @@ -{"target_phrases":{"idk":"I don't know","hoco":"homecoming","bbl":"be back later","bbg":"baby girl","mb":"my bad","mfw":"my face when","tfw":"that face when","ebr":"East Baton Rouge","ttyl":"talk to you later","ab":"about","abt":"about","dk":"don't know","prolly":"probably","tbh":"to be honest","smh":"shaking my head","btw":"by the way","ngl":"not gonna lie","fr":"for real","yessss":"yes","bc":"because","u":"you","thru":"through","lmao":"laughing my ass off","tldr":"too long; didn't read","ofc":"of course","linux":"GNU/Linux","xfl":"Extreme Football League","bi":"bisexual","abbr":"abbreviation","jk":"just kidding","gm":"good morning","mc":"Minecraft","nfl":"National Football League","ygd":"you're gonna die","gn":"goodnight","gac":"Great American Cookie","ncaa":"National Collegiate Athletic Association","em":"them","tbf":"to be fair","ppl":"people","bb":"baby","stfu":"shut the frick up","nvm":"nevermind","idc":"I don't care","dc":"don't care","ty":"thank you","yw":"you're welcome","lol":"laughing out loud","ok":"okay","sout":"System.out.println(\"\");","serr":"System.err.println(\"\");","psvm":"public static void main(String[] args) { }","rn":"right now","osjhs":"I made it up"}} \ No newline at end of file +{"target_phrases":{"idk":"I don't know","hoco":"homecoming","bbl":"be back later","bbg":"baby girl","mb":"my bad","mfw":"my face when","tfw":"that face when","ebr":"East Baton Rouge","ttyl":"talk to you later","ab":"about","abt":"about","dk":"don't know","prolly":"probably","tbh":"to be honest","smh":"shaking my head","btw":"by the way","ngl":"not gonna lie","fr":"for real","yessss":"yes","bc":"because","u":"you","thru":"through","lmao":"laughing my ass off","tldr":"too long; didn't read","ofc":"of course","linux":"GNU/Linux","xfl":"Extreme Football League","bi":"bisexual","abbr":"abbreviation","jk":"just kidding","gm":"good morning","mc":"Minecraft","nfl":"National Football League","ygd":"you're gonna die","gn":"goodnight","gac":"Great American Cookie","ncaa":"National Collegiate Athletic Association","em":"them","tbf":"to be fair","ppl":"people","bb":"baby","stfu":"shut the frick up","nvm":"nevermind","idc":"I don't care","dc":"don't care","ty":"thank you","yw":"you're welcome","lol":"laughing out loud","ok":"okay","sout":"System.out.println(\"\");","serr":"System.err.println(\"\");","psvm":"public static void main(String[] args) { }","rn":"right now","osjhs":"I made it up","trans":"transgender","js":"JavaScript"}} \ No newline at end of file From d498d663e2aee5dc7e3a5ff933c0b1d344c27de5 Mon Sep 17 00:00:00 2001 From: Caleb Fontenot Date: Tue, 4 Apr 2023 12:26:22 -0500 Subject: [PATCH 2/3] Mention bug in code --- main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.ts b/main.ts index 5c3cfe5..01e6dd4 100644 --- a/main.ts +++ b/main.ts @@ -159,7 +159,7 @@ function checkMessage(message) { message.reply("Detected abbreviation, but regex matching broke. Caleb is working on this..."); break; } - + //https://gitea.calebfontenot.com/CCF_100/NoMoreAcronyms/issues/1 arrayRotate(rebuildMessageArray, true, 1); rebuildMessageArray.unshift("`" + phrase + "`"); arrayRotate(rebuildMessageArray, true, 2); From 22e3be26db422866327128547dd902e113d74bc0 Mon Sep 17 00:00:00 2001 From: Caleb Fontenot Date: Tue, 4 Apr 2023 12:59:58 -0500 Subject: [PATCH 3/3] Refactor exemption checking --- main.ts | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/main.ts b/main.ts index 01e6dd4..145acb7 100644 --- a/main.ts +++ b/main.ts @@ -131,17 +131,8 @@ function checkMessage(message) { //console.log("Corrected Message: " + correctedMessage); if (abbreviationKey.target_phrases[matchMessageArray[i]] !== undefined) { - console.log("Has role? " + message.member.roles.cache.some(role => role.name == "Exempt from NoMoreAcronyms")); - if (!message.author.bot) { - if (message.member.roles.cache.some(role => role.name == "Exempt from NoMoreAcronyms")) { - if (!message.member.roles.cache.some(role => role.name == "NoReactions")) { - message.react('🇵'); - message.react('🇴'); - message.react('🇬'); - return; - } - return; - } + if (checkIfExempt(message)) { + return; } matchDetected = true; abbrsUsed++; @@ -157,7 +148,7 @@ function checkMessage(message) { console.log("rebuildMessageArray: " + rebuildMessageArray); } else { message.reply("Detected abbreviation, but regex matching broke. Caleb is working on this..."); - break; + return; } //https://gitea.calebfontenot.com/CCF_100/NoMoreAcronyms/issues/1 arrayRotate(rebuildMessageArray, true, 1); @@ -179,6 +170,22 @@ function checkMessage(message) { } } +function checkIfExempt(message) { + console.log("Has role? " + message.member.roles.cache.some(role => role.name == "Exempt from NoMoreAcronyms")); + if (!message.author.bot) { + if (message.member.roles.cache.some(role => role.name == "Exempt from NoMoreAcronyms")) { + if (!message.member.roles.cache.some(role => role.name == "NoReactions")) { + message.react('🇵'); + message.react('🇴'); + message.react('🇬'); + return true; + } + return true; + } + } + return false; +} + function checkInsult(message) { if (!message.author.bot) { if (!message.member.roles.cache.some(role => role.name == "Exempt from NoMoreAcronyms")) {