First working build™️
This commit is contained in:
parent
efa6dfcf7e
commit
45cd83fd38
22
main.ts
22
main.ts
@ -71,9 +71,9 @@ var abbreviationKey = require("./abbreviation_key.json");
|
||||
|
||||
function arrayRotate(arr, reverse, amount) {
|
||||
for (var i = 0; i < amount; i++) {
|
||||
if (reverse) arr.unshift(arr.pop());
|
||||
else arr.push(arr.shift());
|
||||
return arr;
|
||||
if (reverse) arr.unshift(arr.pop());
|
||||
else arr.push(arr.shift());
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,15 +81,15 @@ function matchAbbr(abbrTarget) {
|
||||
console.log("Looking for: " + abbrTarget);
|
||||
for (var abbr in abbreviationKey.target_phrases) {
|
||||
if (abbreviationKey.target_phrases[abbr] == abbrTarget) {
|
||||
console.log("abbrTarget:" + typeof(abbrTarget));
|
||||
console.log("abbr: " + typeof(abbr));
|
||||
console.log("abbrTarget: " + typeof (abbrTarget));
|
||||
console.log("abbr: " + typeof (abbr));
|
||||
return abbr;
|
||||
} else {
|
||||
console.log("abbrTarget:" + typeof(abbrTarget));
|
||||
console.log("abbr: " + typeof(abbr));
|
||||
return "";
|
||||
console.log("abbrTarget: " + typeof (abbrTarget));
|
||||
console.log("abbr: " + typeof (abbr));
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function replyMessage(message, correctedMessage) {
|
||||
@ -109,7 +109,9 @@ client.on('messageCreate', message => {
|
||||
if (abbreviationKey.target_phrases[matchMessageArray[i]] !== undefined) {
|
||||
//Return key
|
||||
var phrase = abbreviationKey.target_phrases[matchMessageArray[i]];
|
||||
var abbr = matchAbbr(phrase);
|
||||
|
||||
var abbr = matchAbbr(phrase); //abbreviationKey.target_phrases[phrase];
|
||||
console.log(typeof(abbr));
|
||||
|
||||
console.log("Found abbreviation: " + abbr);
|
||||
console.log("Phrase that matches used acronym: " + phrase);
|
||||
@ -119,7 +121,7 @@ client.on('messageCreate', message => {
|
||||
message.reply("Detected abbreviation, but regex matching broke. Caleb is working on this...");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
arrayRotate(rebuildMessageArray, true, 1);
|
||||
rebuildMessageArray.unshift(phrase);
|
||||
arrayRotate(rebuildMessageArray, true, 2);
|
||||
|
Loading…
Reference in New Issue
Block a user