rorFunctions.lua 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. function chiamaEsterno(_trunks)
  2. return function (context, ext)
  3. app.noop(ext)
  4. app.noop(context)
  5. if ext:sub(1,1) == "0" then
  6. num = ext:sub(2) -- butta via lo 0 iniziale
  7. trunks = _trunks;
  8. else
  9. num = ext:sub(3) -- butta via l'*1 o *2
  10. trunks = { _trunks[tonumber(ext:sub(2,2))] };
  11. end
  12. if context == "from-regia" then
  13. -- qui NON ci va il doppio underscore: solo chi chiama puo' usare questa feature
  14. app.set("DYNAMIC_FEATURES=mandainondaChiamante")
  15. -- XXX: vogliamo che #9 non faccia proprio niente se sei un interno non di regia?
  16. -- o vorremmo tipo che facendo #9 da from-interni inoltrasse la chiamata alla regia?
  17. end
  18. to_dial = ""
  19. for i, trunk in ipairs(trunks) do
  20. if i > 1 then
  21. to_dial = to_dial .. "&"
  22. end
  23. dial_s = string.format("%s%s@%s", SIP, num, trunk)
  24. app.dial(dial_s, nil, "g")
  25. app.noop("DIALSTATUS=" .. channel.DIALSTATUS.value)
  26. if channel.DIALSTATUS.value ~= "CHANUNAVAIL" then
  27. app.noop("esco ciao")
  28. break
  29. end
  30. end
  31. end
  32. end
  33. function chiamaDaEsterno(_interni)
  34. return function()
  35. to_dial = ""
  36. for _, num in ipairs(INTERNI) do
  37. if #to_dial > 0 then
  38. to_dial = to_dial .. "&"
  39. end
  40. to_dial = to_dial .. SIP .. num
  41. end
  42. app.set("__DYNAMIC_FEATURES=mandainondaRicevente")
  43. app.dial(to_dial)
  44. end
  45. end