Hi I am trying to call a function within a for loop but It isn't working...This is how my code currently looks like:
(嗨,我正在尝试在for循环中调用一个函数,但是它不起作用...这是我的代码当前的样子:)
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);
};
I want the function notifyProblemSolver() to be called in the for loop...But if I run the code it isn't working.
(我希望在for循环中调用函数notifyProblemSolver()...但是如果我运行代码,它将无法正常工作。)
Any tips?(有小费吗?)
Thanks in advance!(提前致谢!)
ask by Martijn_- translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…