micro365/social-interaction/receiveMention.mjs

28 lines
810 B
JavaScript
Raw Normal View History

2023-08-12 09:43:37 +00:00
import logger from "../logger.mjs"
import { checkSpelling } from "spellchecker"
2023-08-13 13:00:24 +00:00
import { wordIsAlreadyInBuffer, getAcceptablePrompts } from "../database-calls/db.mjs"
2023-08-12 09:43:37 +00:00
export default async function (note) {
const childLogger = logger.child({note})
childLogger.trace("receiveMention called")
const textArray = note.text
.replace(/@[a-z,A-Z,0-9]* /g, "")
.trim()
.match(/[a-z]*/ig)
if(textArray.length===1){
const word = textArray[0]
if(checkSpelling(word)){
if(await getAcceptablePrompts().indexOf(word)!=-1){
2023-08-12 17:17:09 +00:00
if(!wordIsAlreadyInBuffer(word)){
2023-08-12 10:05:24 +00:00
2023-08-13 13:00:24 +00:00
// }
2023-08-12 09:43:37 +00:00
}
}
//ETC
}else if(textArray.length>1){
//"Please reply with one word, I'm only a bot etc etc"
}
}