I am working on a chatbot for school that solves problems in my school. So basically I'm stuck on this part because I have no idea how to do this...
- I want to check if a certain value in a sentence is equal to a value in my array.
- If it is equal to a value in my array, then I want my chatbot to write a message to another channel containing that variable
So lets say I have the sentence:
Hi, I have a problem in classroom 108
The value "classroom 108" is equal to the value "classroom 108" in my array.
var classroom= [
{
L108: ["classroom 108","L108"]
},{
L208: ["classroom 208","L208"]
}
];
So now I want to write a message to another channel containing the variable "L108".
function handleMessage(message) {
classroom.forEach((value, index) => {
if (message.includes(classroom)) {
classroom();
console.log(message);
};
})
};
function classroom(message) {
const params = {
icon_emoji: ':smiley:'
}
textchannel = probleemoplosser + ", een docent heeft een probleem met het " + probleem + " in ",classroom, params;
reactie = "Top, ik heb het doorgegeven aan " + naam;
bot.postMessageToChannel( otherchannel,textchannel,params);
bot.postMessageToChannel('general',reactie, params);
};
I don't have much experience with JavaScript so any help is welcome...thanks in advance!<3