JSFiddle - React, Tailwind, and code Playground

by terza_terza

JavaScript

bot.on('message', data => {
    if (data.type !== 'message' || data.subtype === 'bot_message') {
        return;
    }
    findClassroomMention(data,text);
});

var classrooms = 
    {
        L108: ["lokaal 108","L108","108"],
        L208: ["lokaal 208","L208","208"]
    };

function findClassroomMention(message) {    
    var found = false   
    for(var ClassroomId in classrooms) {
        for(var term of classrooms[ClassroomId]) {
            if(message.includes(term)) {
                found = ClassroomId;
                notifyProblemSolver();
                break;
            }
        }
        if (found) notifyProblemSolver(); break;
    }
    return found
}

function notifyProblemSolver(ClassroomId) {
    const params = {
        icon_emoji: ':smiley:'
    }
    bot.postMessageToChannel('caris','We have a problem in' + ClassroomId, params);
}