Merge branch 'master' of ssh://gitea.calebfontenot.com:25566/CCF_100/NoMoreAcronyms

master
Chloe Fontenot 🏳️‍⚧️ 2023-04-10 23:58:55 +07:00
commit 969db85535
3 changed files with 29 additions and 10 deletions

@ -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","abt":"about","ab":"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","gc":"group chat","vc":"voice chat"}}
{"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","abt":"about","ab":"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","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","gc":"group chat","vc":"voice chat","ur":"your","gb":"great Britain"}}

@ -1,5 +1,5 @@
{
"token": "MTA5MTEyMDI2Nzg1MTQ4NTIxNQ.GUw1W5.SGkSWCfeyAs6cktoAhVE4ivkKAI5kGfhw-8wRc",
"clientId": "1091120267851485215",
"guildId": "475327576110268466"
}
"guildId": "1009146338782490724"
}

@ -1,6 +1,6 @@
"use strict";
// Require the necessary discord.js classes
const { Client, Events, GatewayIntentBits, REST, Routes, Collection, FLAGS, MessageMentionOptions, codeBlock, SlashCommandBuilder } = require('discord.js');
const { Client, Events, GatewayIntentBits, REST, Routes, Collection, FLAGS, MessageMentionOptions, codeBlock, SlashCommandBuilder, blockQuote } = require('discord.js');
const Discord = require('discord.js');
const { clientId, guildId, token } = require('./key.json');
let fs = require('node:fs');
@ -106,7 +106,7 @@ function replyMessage(message, correctedMessage, abbrsUsed) {
} else {
plural = abbrsUsed + " acronyms"
}
var replyString = "Your message contains " + plural + "! Let me fix that for you: \n > " + correctedMessage + "\n \n \|\|btw I was written by Caleb Fontenot\|\|"
var replyString = "Your message contains " + plural + "! Let me fix that for you: \n"+ " \|\|btw I was written by Caleb Fontenot\|\| \n \n" + blockQuote(correctedMessage);
var stringLength = replyString.length;
if (stringLength > 2000) {
@ -128,6 +128,21 @@ client.on('messageUpdate', (undefined, newMessage) => {
});
function getMatchingPhrase(inputString, targetCharacter) {
const words = inputString.split(/\s+/);
let matchingPhrase = null;
for (let i = 0; i < words.length; i++) {
const word = words[i];
if (word.includes(targetCharacter)) {
matchingPhrase = abbreviationKey.target_phrases[word];
if (matchingPhrase) {
break;
}
}
}
return matchingPhrase;
}
global.checkMessage = function checkMessage(message, runFromGlobal) {
if (!runFromGlobal) {
checkInsult(message);
@ -140,8 +155,8 @@ global.checkMessage = function checkMessage(message, runFromGlobal) {
console.log(`${message.author.tag} in #${message.channel.name} sent: ${message.content}`);
}
//console.log(message.author);
var matchMessageArray = message.content.toLowerCase().split(/[\\\' ,!?\"@#$%^&*().;:|]+/);
var matchMessageArray = message.content.toLowerCase().split(/\W/g);
// /[\\\' ,!?\"@#$%^&*().;:|]+/
console.log(matchMessageArray);
let correctedMessage = message.content;
let matchDetected = false;
@ -167,19 +182,23 @@ global.checkMessage = function checkMessage(message, runFromGlobal) {
console.log("Found abbreviation: " + abbr);
console.log("Phrase that matches used acronym: " + phrase);
if (abbr !== "") {
rebuildMessageArray = correctedMessage.split(new RegExp(abbr, 'i'));
console.log("rebuildMessageArray: " + rebuildMessageArray);
// let regex = new RegExp(`^(.*?)${ '\\b' + abbr + '\\b'}`, 'i');
let regex = new RegExp(`^((?:.*?\n)*?.*?)${ '\\b' + abbr + '\\b'}`, 'i');
rebuildMessageArray = correctedMessage.split(regex);
console.log("rebuildMessageArray: ", rebuildMessageArray);
} else {
message.reply("Detected abbreviation, but regex matching broke. Caleb is working on this...");
return;
}
//https://gitea.calebfontenot.com/CCF_100/NoMoreAcronyms/issues/1
//Insert phrase into string
arrayRotate(rebuildMessageArray, true, 1);
rebuildMessageArray.unshift("`" + phrase + "`");
arrayRotate(rebuildMessageArray, true, 2);
console.log(rebuildMessageArray);
// Build into string and set to variable!
correctedMessage = ""; // clear old message.
correctedMessage = "" // clear old message.
for (let j = 0; j < rebuildMessageArray.length; j++) {
correctedMessage += rebuildMessageArray[j];
}