Node.js - 请求userInput直到满足条件?

时间:2017-03-22 09:19:08

标签: javascript node.js

我是Node.js的新手。我正在尝试执行以下代码来重复if-then-else循环,直到用户输入正确的数据。然而,该函数在最后一个'中被调用。但是在调用函数之前不会显示消息。有人可以帮帮我吗?

intents.matches('Work type', [
    function xyz(session,args) {
    builder.Prompts.text(session ,"How much is the square feet . Please type \n\n 1 for >2000 sq ft \n\n 2 for <2000 sq ft");
    },
    function abc(session, results) {
        var res = results.response;
        if (res == 1)
            {
                session.send('You can go for Dr. Fixit Newcoat \n Is is a heavy duty terrace waterproof coating system. \n \n 1.Solid Content \n\n 2.Hardness Shore A:  ASTM D 2240 2002 \n\n 3.Tensile Strength N/mm2:ASTM D 412 2002 \n\n 4.Elongation at Break:ASTM D 412 2002 \n\n 5.UV Resistant - Accelerated:ASTM G 154 2000 \n\n Are you satisfied with the solution ?');
            }
        else if (res == 2)
            {
                session.send('You can go for Dr. Fixit New Coat Ezee    \n \n Area of Application- Building roofs/terrace - Flats and Sloping  \n\n OverExisting cementicious waterproofing treatments like \n\n 1.Brickbat \n\n 2.Coba \n\n 3.Concreet screeds \n\n 4.Acrylic coating etc. \n\n Available package : \n\n 1. 4 ltrs : Rs 2000 \n\n 2. 12 ltrs : Rs 5000 \n\n Are you satisfied with the solution ?');   
            }
        else
            {
                session.send('You have entered an in correct input . Please input 1 or 2 as per your requirment');
                abc(session, results);
            }

   }
])

0 个答案:

没有答案