lua中的IVR脚本

时间:2014-04-03 07:09:06

标签: lua goto ivr

我在lua中创建了一个ivr脚本。在此脚本中,goto语句不起作用。请有人告诉我这段代码有什么问题。如果我删除 :: chandu :: elseif(digits ==“0”)然后转到chandu 那么它运行正常。但是添加goto语句调用没有连接,或者我可以说脚本没有运行。

                 .

i = 0 j = 0

while(session:ready()== true)do
  会话:setAutoHangup(假);

重复         :: chandu ::

 digits = session:playAndGetDigits(1, 3, 3, 3000, "#", "/var/sipxdata/mediaserver/data/ivrscript/sampleLua/prompts/coral.wav", "/var/sipxdata/mediaserver/data/ivrscript/sampleLua/prompts/coral.wav", "\\d+"); 
    if (digits == "1")  then

        repeat

             digits = session:playAndGetDigits(1, 3, 3, 3000, "#", "/var/sipxdata/mediaserver/data/ivrscript/sampleLua/prompts/SPG_greet_long.wav","/var/sipxdata/mediaserver/data/ivrscript/sampleLua/prompts/SPG_greet_long.wav", "\\d+");
            if (digits == "1")  then
               language = "de"
               session:execute("set","transfer_ringback=$${us-ring}");
               session:execute("bridge","sofia/coraltele.com/819@192.168.22.1");
               session:hangup();


            elseif (digits == "2")  then
                language = "de"
                session:execute("set","transfer_ringback=$${us-ring}");
                session:execute("bridge","sofia/coraltele.com/826@192.168.22.1");
                session:hangup();

            elseif (digits == "9") then
                i = i + 1

            elseif (digits == "0") then

                goto chandu


            else
                language = "de"
                session:execute("set","transfer_ringback=$${us-ring}");
                session:execute("bridge","sofia/coraltele.com/898@192.168.22.1");
                session:hangup();

            end
                   until i == 3


    elseif(digits == "0") then

        j = j + 1

    else
        language = "de"
        session:execute("set","transfer_ringback=$${us-ring}");
        session:execute("bridge","sofia/coraltele.com/898@192.168.1.240");
        session:hangup();
    end
until j == 2

 language = "de"
 session:execute("set","transfer_ringback=$${us-ring}");
 session:execute("bridge","sofia/coraltele.com/898@192.168.1.240");
 session:hangup();  

1 个答案:

答案 0 :(得分:0)

最后我创建了一个完全正常工作的脚本。

i = 0 j = 0

while(session:ready()== true)do

会话:setAutoHangup(假);

重复

digits = session:playAndGetDigits(1,3,3,3000,“#”,“/ var / sipxdata / mediaserver / data / ivrscript / samplesLua / promts / coral.wav”,“shout://translate.google” .com / translate_tts?tl = en& q =这个+选项+是+ not + valid“,”\ d +“);

if (digits == "1")  then

    repeat 

    digits = session:playAndGetDigits(1, 3, 3, 3000, "#", "/var/sipxdata/mediaserver/data/ivrscript/sampleLua/prompts/corporate_greet_long.wav","shout://translate.google.com/translate_tts?tl=en&q=This+option+is+not+valid", "\\d+");
    if (digits == "1")  then
    language = "de"
    session:execute("set","transfer_ringback=$${us-ring}");
    session:execute("bridge","sofia/coraltele.com/819@192.168.1.240");
    session:hangup();
    destroy(0);

  elseif (digits == "2")  then
    language = "de"
    session:execute("set","transfer_ringback=$${us-ring}");
    session:execute("bridge","sofia/coraltele.com/826@192.168.1.240");
    session:hangup();
    destroy(0);

  elseif (digits == "9") then

     i = i + 1


  elseif(digits == "0") then

    i = 0
    j = 0
    break

  else
    language = "de"
    session:execute("set","transfer_ringback=$${us-ring}");
    session:execute("bridge","sofia/coraltele.com/898@192.168.1.240");
    session:hangup();
    destroy(0);       --Destroys the session and releases resources. 
                      --This is done for you when your script ends, 
                      --but if your script contains an infinite loop 
                      --you can use this to terminate the session.
  end

  until i == 3






elseif (digits == "2")  then


  repeat 



  digits = session:playAndGetDigits(1, 3, 3, 3000, "#", "/var/sipxdata/mediaserver/data/ivrscript/sampleLua/prompts/support_greet_long.wav","shout://translate.google.com/translate_tts?tl=en&q=This+option+is+not+valid", "\\d+");
  if (digits == "1")  then
    language = "de"
    session:execute("set","transfer_ringback=$${us-ring}");
    session:execute("bridge","sofia/coraltele.com/825@192.168.1.240");
    session:hangup();
    destroy(0);

  elseif (digits == "2")  then
    language = "de"
    session:execute("set","transfer_ringback=$${us-ring}");
    session:execute("bridge","sofia/coraltele.com/830@192.168.1.240");
    session:hangup();
    destroy(0);


  elseif(digits == "9") then
   i = i + 1



  elseif(digits == "0") then

    i = 0
    j = 0
    break


  else
    language = "de"
    session:execute("set","transfer_ringback=$${us-ring}");
    session:execute("bridge","sofia/coraltele.com/898@192.168.1.240");
    session:hangup();
    destroy(0);
  end

 until i == 3





elseif (digits == "3")  then

    repeat 


   digits = session:playAndGetDigits(1, 3, 3, 3000, "#", "/var/sipxdata/mediaserver/data/ivrscript/sampleLua/prompts/SPG_greet_long.wav","shout://translate.google.com/translate_tts?tl=en&q=This+option+is+not+valid", "\\d+");
  if (digits == "1")  then
    language = "de"
    session:execute("set","transfer_ringback=$${us-ring}");
    session:execute("bridge","sofia/coraltele.com/808@192.168.1.240");
    session:hangup();
    destroy(0);

  elseif (digits == "2")  then
    language = "de"
    session:execute("set","transfer_ringback=$${us-ring}");
    session:execute("bridge","sofia/coraltele.com/878@192.168.1.240");
    session:hangup();
    destroy(0);

   elseif (digits == "9") then

      i = i + 1


   elseif(digits == "0") then

    i = 0
    j = 0
    break

   else
    language = "de"
    session:execute("set","transfer_ringback=$${us-ring}");
    session:execute("bridge","sofia/coraltele.com/898@192.168.1.240");
    session:hangup();
    destroy(0);
  end

   until i == 3




elseif (digits == "4")  then


  repeat 


   digits = session:playAndGetDigits(1, 3, 3, 3000, "#", "/var/sipxdata/mediaserver/data/ivrscript/sampleLua/prompts/SPG_greet_long.wav","shout://translate.google.com/translate_tts?tl=en&q=This+option+is+not+valid", "\\d+");
  if (digits == "1")  then
    language = "de"
    session:execute("set","transfer_ringback=$${us-ring}");
    session:execute("bridge","sofia/coraltele.com/890@192.168.1.240");
    session:hangup();
    destroy(0);

  elseif (digits == "2")  then
    language = "de"
    session:execute("set","transfer_ringback=$${us-ring}");
    session:execute("bridge","sofia/coraltele.com/891@192.168.1.240");
    session:hangup();
    destroy(0);


  elseif (digits == "9") then

    i = i + 1


  elseif(digits == "0") then

    i = 0
    j = 0
    break

  else
    language = "de"
    session:execute("set","transfer_ringback=$${us-ring}");
    session:execute("bridge","sofia/coraltele.com/898@192.168.1.240");
    session:hangup();
    destroy(0);

  end

  until i == 3


elseif (digits == "5")  then

  repeat 


   digits = session:playAndGetDigits(1, 3, 3, 3000, "#", "/var/sipxdata/mediaserver/data/ivrscript/sampleLua/prompts/SPG_greet_long.wav","shout://translate.google.com/translate_tts?tl=en&q=This+option+is+not+valid", "\\d+");

  if (digits == "1")  then
    language = "de"
    session:execute("set","transfer_ringback=$${us-ring}");
    session:execute("bridge","sofia/coraltele.com/851@192.168.1.240");
    session:hangup();
    destroy(0);

  elseif (digits == "2")  then
     language = "de"
     session:execute("set","transfer_ringback=$${us-ring}");
     session:execute("bridge","sofia/coraltele.com/872@192.168.1.240");
     session:hangup();
     destroy(0);

  elseif (digits == "9") then

     i = i + 1


  elseif(digits == "0") then

    i = 0
    j = 0
    break

  else
     language = "de"
     session:execute("set","transfer_ringback=$${us-ring}");
     session:execute("bridge","sofia/coraltele.com/898@192.168.1.240");
     session:hangup();
     destroy(0);

  end

  until i == 3

elseif(digits == "0") then

     j = j + 1

else
    language = "de"
    session:execute("set","transfer_ringback=$${us-ring}");
    session:execute("bridge","sofia/coraltele.com/898@192.168.1.240");
    session:hangup();
    destroy(0);
end
until j == 2