Update confirm.lua

This commit is contained in:
Mark Crane 2014-08-14 03:35:59 +00:00
parent 8d460b1148
commit 4aa3e3e2aa
1 changed files with 62 additions and 50 deletions

View File

@ -16,21 +16,31 @@
--
-- The Initial Developer of the Original Code is
-- Mark J Crane <markjcrane@fusionpbx.com>
-- Copyright (C) 2010
-- Copyright (C) 2010-2014
-- the Initial Developer. All Rights Reserved.
--
-- Contributor(s):
-- Mark J Crane <markjcrane@fusionpbx.com>
max_tries = "3";
digit_timeout = "5000";
--set variables
max_tries = "3";
digit_timeout = "5000";
if ( session:ready() ) then
--run if the session is ready
if ( session:ready() ) then
--answer the call
session:answer();
--get the variables
context = session:getVariable("context");
sounds_dir = session:getVariable("sounds_dir");
destination_number = session:getVariable("destination_number");
--confirm or not to confirm
if (session:getVariable("confirm")) then
confirm = session:getVariable("confirm");
end
--prepare the api
api = freeswitch.API();
@ -43,18 +53,19 @@ if ( session:ready() ) then
if (not default_voice) then default_voice = 'callie'; end
--confirm the calls
--set the default
prompt_for_digits = true;
--if an extension answer the call
-- user_exists id 1005 voip.fusionpbx.com
if (confirm) then
cmd = "user_exists id ".. destination_number .." "..context;
result = api:executeString(cmd);
freeswitch.consoleLog("NOTICE", "[confirm] "..cmd.." --"..result.."--\n");
--freeswitch.consoleLog("NOTICE", "[confirm] "..cmd.." "..result.."\n");
if (result == "true") then
prompt_for_digits = false;
confirm = "true";
end
end
--prompt for digits
if (prompt_for_digits) then
if (confirm == "true") then
--send to the log
--freeswitch.consoleLog("NOTICE", "[confirm] prompt\n");
--get the digit
min_digits = 1;
max_digits = 1;
@ -73,6 +84,7 @@ if ( session:ready() ) then
session:hangup("NO_ANSWER");
end
else
--send to the log
--freeswitch.consoleLog("NOTICE", "[confirm] automatically accepted\n");
end
end
end