Added new AST_activity_log_export.pl script to export selected data and send to an FTP server git-svn-id: svn://192.168.202.10@3082 3d104415-ff17-0410-8863-d5cf3c621b8a
1354 lines
50 KiB
Perl
1354 lines
50 KiB
Perl
#!/usr/bin/perl
|
|
#
|
|
# VD_amd.agi version 2.14
|
|
#
|
|
# runs after a call goes through AMD in extensions.conf to send the call on to
|
|
# it's proper destination, or when agent sends to VM message
|
|
#
|
|
# You need to put lines similar to those below in your extensions.conf file:
|
|
#
|
|
# ; VICIDIAL_auto_dialer transfer script AMD with Load Balanced:
|
|
# exten => 8369,1,AGI(call_log.agi,${EXTEN})
|
|
# exten => 8369,2,(AMD),AMD
|
|
# exten => 8369,3,AGI(VD_amd.agi,${EXTEN}-----NO)
|
|
# exten => 8369,4,AGI(agi-VDAD_LB_transfer.agi,${EXTEN})
|
|
# exten => 8369,5,AGI(agi-VDAD_LB_transfer.agi,${EXTEN})
|
|
# exten => 8369,6,AGI(agi-VDAD_LB_transfer.agi,${EXTEN})
|
|
# exten => 8369,7,Hangup
|
|
#
|
|
# exten => 8320,1,AGI(VD_amd.agi,${EXTEN}-----YES)
|
|
# exten => 8320,2,Hangup
|
|
# exten => _8320*.,1,AGI(VD_amd.agi,${EXTEN}-----YES)
|
|
# exten => _8320*.,2,Hangup
|
|
#
|
|
# Copyright (C) 2019 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
|
#
|
|
# changes:
|
|
# 60206-1434 - first build
|
|
# 60207-1205 - added database records entries/modifications
|
|
# 60207-1507 - added ability to send AMs to campaign-defined message to leave
|
|
# 60731-1407 - changed to use DBI-DBD::mysql
|
|
# - changed to use /etc/astguiclient.conf for configs
|
|
# 60815-1310 - added output options check from database
|
|
# 71118-0252 - compatibility with Asterisk 1.4, added AA and AM statuses
|
|
# 90916-1317 - Changed to audio file playback and TTS playback
|
|
# 90924-1533 - Added answering machine message list_id override option
|
|
# 100205-1025 - Fixed CPD send to message
|
|
# 100327-0819 - Fixed issue with Manual dial treansfers
|
|
# 100430-1606 - Added list_id update to vicidial_log updates
|
|
# 100823-0850 - Changed vac to UPDATE for Auto-alt-dial to function properly
|
|
# 100903-0041 - Changed lead_id max length to 10 digits
|
|
# 101111-1552 - Fixed minor bug in TTS filtering
|
|
# 110324-2334 - Logging changes made
|
|
# 110812-1515 - Added static tts file parsing and replacement
|
|
# 110926-1902 - Added extended logging and additional waitforsilence options
|
|
# 120430-2214 - Converted call to Monitor app to be asterisk 1.8 compatible
|
|
# 130108-1808 - Changes for Asterisk 1.8 compatibility
|
|
# 130210-1113 - Added options for CALLMENU|INGROUP cpd_amd_actions
|
|
# 140312-2110 - Added CALLID as recording filename variable
|
|
# 141211-1634 - Added cpd_unknown_action campaign option
|
|
# 150223-1443 - Added DYN filename prefix for non-TTS dynamic files to be used for am message
|
|
# 151109-1708 - Added new campaign feature allowing for different messages based on answering machine message wildcards
|
|
# 170426-1711 - Fixed double-logging issue
|
|
# 180529-1707 - Fix for missing called_count value in vicidial_log insertions
|
|
# 180919-1831 - Fix for logging issue
|
|
# 180924-1557 - Added called_count as AMM wildcard
|
|
# 190216-0813 - Fix for user-group, in-group and campaign allowed/permissions matching issues
|
|
# 190320-2331 - Added more logging options
|
|
#
|
|
|
|
$script = 'VD_amd.agi';
|
|
|
|
$A = 1; # set to 1 for AMD output messages mode
|
|
$AMD_LOG = 3; # set to 1 for logfile and 2 forDB log, 3 for both
|
|
$wav='.wav';
|
|
|
|
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
|
|
$year = ($year + 1900);
|
|
$mon++;
|
|
if ($mon < 10) {$mon = "0$mon";}
|
|
if ($mday < 10) {$mday = "0$mday";}
|
|
if ($hour < 10) {$hour = "0$hour";}
|
|
if ($min < 10) {$min = "0$min";}
|
|
if ($sec < 10) {$sec = "0$sec";}
|
|
|
|
$now_date_epoch = time();
|
|
$now_date = "$year-$mon-$mday $hour:$min:$sec";
|
|
$file_day = "$year$mon$mday";
|
|
|
|
# default path to astguiclient configuration file:
|
|
$PATHconf = '/etc/astguiclient.conf';
|
|
|
|
open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n";
|
|
@conf = <conf>;
|
|
close(conf);
|
|
$i=0;
|
|
foreach(@conf)
|
|
{
|
|
$line = $conf[$i];
|
|
$line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi;
|
|
if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) )
|
|
{$PATHhome = $line; $PATHhome =~ s/.*=//gi;}
|
|
if ( ($line =~ /^PATHlogs/) && ($CLIlogs < 1) )
|
|
{$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;}
|
|
if ( ($line =~ /^PATHagi/) && ($CLIagi < 1) )
|
|
{$PATHagi = $line; $PATHagi =~ s/.*=//gi;}
|
|
if ( ($line =~ /^PATHweb/) && ($CLIweb < 1) )
|
|
{$PATHweb = $line; $PATHweb =~ s/.*=//gi;}
|
|
if ( ($line =~ /^PATHsounds/) && ($CLIsounds < 1) )
|
|
{$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;}
|
|
if ( ($line =~ /^PATHmonitor/) && ($CLImonitor < 1) )
|
|
{$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;}
|
|
if ( ($line =~ /^VARserver_ip/) && ($CLIserver_ip < 1) )
|
|
{$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;}
|
|
if ( ($line =~ /^VARDB_server/) && ($CLIDB_server < 1) )
|
|
{$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;}
|
|
if ( ($line =~ /^VARDB_database/) && ($CLIDB_database < 1) )
|
|
{$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;}
|
|
if ( ($line =~ /^VARDB_user/) && ($CLIDB_user < 1) )
|
|
{$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;}
|
|
if ( ($line =~ /^VARDB_pass/) && ($CLIDB_pass < 1) )
|
|
{$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;}
|
|
if ( ($line =~ /^VARDB_port/) && ($CLIDB_port < 1) )
|
|
{$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;}
|
|
$i++;
|
|
}
|
|
|
|
if (!$VARDB_port) {$VARDB_port='3306';}
|
|
if (!$AGILOGfile) {$AGILOGfile = "$PATHlogs/agiout.$year-$mon-$mday";}
|
|
if (!$CEPLOGfile) {$CEPLOGfile = "$PATHlogs/Cepstral.$year-$mon-$mday";}
|
|
|
|
use DBI;
|
|
use Asterisk::AGI;
|
|
$AGI = new Asterisk::AGI;
|
|
|
|
|
|
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
|
|
or die "Couldn't connect to database: " . DBI->errstr;
|
|
|
|
### Grab Server values from the database
|
|
$stmtA = "SELECT agi_output,asterisk_version,ext_context FROM servers where server_ip = '$VARserver_ip';";
|
|
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
|
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
|
$sthArows=$sthA->rows;
|
|
if ($sthArows > 0)
|
|
{
|
|
$AGILOG = '0';
|
|
@aryA = $sthA->fetchrow_array;
|
|
$DBagi_output = $aryA[0];
|
|
$asterisk_version = $aryA[1];
|
|
$DBext_context = $aryA[2];
|
|
if ($DBext_context) {$ext_context = $DBext_context;}
|
|
if ($DBagi_output =~ /STDERR/) {$AGILOG = '1';}
|
|
if ($DBagi_output =~ /FILE/) {$AGILOG = '2';}
|
|
if ($DBagi_output =~ /BOTH/) {$AGILOG = '3';}
|
|
}
|
|
$sthA->finish();
|
|
|
|
### begin parsing run-time options ###
|
|
if (length($ARGV[0])>1)
|
|
{
|
|
if ($AGILOG)
|
|
{$agi_string = "Perl Environment Dump:"; &agi_output;}
|
|
$i=0;
|
|
while ($#ARGV >= $i)
|
|
{
|
|
$args = "$args $ARGV[$i]";
|
|
if ($AGILOG) {$agi_string = "$i|$ARGV[$i]"; &agi_output;}
|
|
$i++;
|
|
}
|
|
|
|
### list of command-line array arguments:
|
|
@ARGV_vars = split(/-----/, $ARGV[0]);
|
|
$CLI_exten = $ARGV_vars[0];
|
|
$force_playback = $ARGV_vars[1];
|
|
}
|
|
|
|
|
|
$|=1;
|
|
while(<STDIN>)
|
|
{
|
|
chomp;
|
|
last unless length($_);
|
|
if ($AGILOG)
|
|
{
|
|
if (/^agi_(\w+)\:\s+(.*)$/)
|
|
{
|
|
$AGI{$1} = $2;
|
|
}
|
|
}
|
|
|
|
if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $1; $uniqueid = $unique_id;}
|
|
if (/^agi_priority\:\s+(.*)$/) {$priority = $1;}
|
|
if (/^agi_channel\:\s+(.*)$/) {$channel = $1;}
|
|
if (/^agi_extension\:\s+(.*)$/) {$extension = $1;}
|
|
if (/^agi_type\:\s+(.*)$/) {$type = $1;}
|
|
if (/^agi_callerid\:\s+(.*)$/) {$callerid = $1; $calleridnum = $callerid;}
|
|
if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;}
|
|
}
|
|
|
|
# extension variables if set: 8320*TESTCAMP*1*9998888112*194239
|
|
if ($extension =~ /\*/)
|
|
{
|
|
@EXT_vars = split(/\*/, $extension);
|
|
$referring_extension = $EXT_vars[0];
|
|
$CLIcampaign_id = $EXT_vars[1];
|
|
$CLIphone_code = $EXT_vars[2];
|
|
$CLIphone_number = $EXT_vars[3];
|
|
$CLIlead_id = $EXT_vars[4];
|
|
}
|
|
|
|
if ( (length($callerid)>20) && ($callerid =~ /\"\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) )
|
|
{
|
|
$callerid =~ s/^\"//gi;
|
|
$callerid =~ s/\".*$//gi;
|
|
# ### set the callerid to the ACQS value(calleridname)
|
|
# print "SET CALLERID $callerid\n";
|
|
# checkresult($result);
|
|
# print STDERR "callerID changed: $callerid\n";
|
|
}
|
|
if ( (
|
|
(length($calleridname)>5) && ( (!$callerid) or ($callerid =~ /unknown|private|00000000/i) or ($callerid =~ /5551212/) )
|
|
) or ( (length($calleridname)>17) && ($calleridname =~ /\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) ) )
|
|
{
|
|
$callerid = $calleridname;
|
|
# ### set the callerid to the ACQS value(calleridname)
|
|
# print "SET CALLERID $callerid\n";
|
|
# checkresult($result);
|
|
# print STDERR "callerID changed: $callerid\n";
|
|
}
|
|
|
|
|
|
if ($AGILOG) {$agi_string = "AGI Environment Dump:"; &agi_output;}
|
|
|
|
foreach $i (sort keys %AGI)
|
|
{
|
|
if ($AGILOG) {$agi_string = " -- $i = $AGI{$i}"; &agi_output;}
|
|
}
|
|
|
|
if ($AGILOG) {$agi_string = "AGI Variables: |$unique_id|$channel|$extension|$type|$callerid|"; &agi_output;}
|
|
|
|
|
|
$VDADcampaign='';
|
|
$VDADphone='';
|
|
$VDADphone_code='';
|
|
|
|
$callerid =~ s/\"//gi;
|
|
$callerid =~ s/ .*//gi;
|
|
$CIDlead_id = $callerid;
|
|
$CIDlead_id = substr($CIDlead_id, 10, 10);
|
|
$CIDlead_id = ($CIDlead_id + 0);
|
|
if ( ($CLIlead_id > 0) && ($CIDlead_id < 1) ) {$CIDlead_id = $CLIlead_id;}
|
|
$VD_lead_id = $CIDlead_id;
|
|
|
|
if ($AGILOG) {$agi_string = "+++++ VD amd START : |$CIDlead_id|$now_date|$AST_ver|$priority|$calleridname|"; &agi_output;}
|
|
|
|
|
|
if ( ($channel =~ /Local/i) && ($AST_ver !~ /^1\.0\.8|^1\.0\.9/) )
|
|
{
|
|
if ($AGILOG) {$agi_string = "+++++ VDAD START LOCAL CHANNEL: EXITING- $priority"; &agi_output;}
|
|
if ($priority > 2) {sleep(1);}
|
|
exit;
|
|
}
|
|
|
|
|
|
$AMDSTATUS = $AGI->get_variable(AMDSTATUS);
|
|
$AMDCAUSE = $AGI->get_variable(AMDCAUSE);
|
|
$AMDSTATS = $AGI->get_variable(AMDSTATS);
|
|
$AMDRESPONSE = $AMDCAUSE;
|
|
$AMDRESPONSE =~ s/-.*//gi;
|
|
$run_time = $AMDSTATS;
|
|
$run_time =~ s/-.*//gi;
|
|
if (length($run_time) < 1) {$run_time=0;}
|
|
|
|
if ($A)
|
|
{
|
|
if ($AGILOG) {$agi_string = "AAAAA AMD results: |$AMDSTATUS|$AMDCAUSE|$AMDSTATS|"; &agi_output;}
|
|
}
|
|
|
|
# Asterisk 1.2.X
|
|
# AAAAA AMD results: |AMD_PERSON|AMD_HUMAN-300-300|
|
|
# AAAAA AMD results: |AMD_MACHINE|AMD_LONGGREETING-1500-1500|
|
|
# Asterisk 1.4.X:
|
|
# AAAAA AMD results: |HUMAN|HUMAN-1000-1000|0000000000|
|
|
# AAAAA AMD results: |MACHINE|MAXWORDS-4-4|0000000000|
|
|
|
|
if ( ($AMD_LOG == 1) || ($AMD_LOG == 3) )
|
|
{
|
|
open(Lout, ">>$PATHlogs/AMD_log".$file_day.".txt")
|
|
|| die "Can't open $PATHlogs/AMD_log".$file_day.".txt: $!\n";
|
|
print Lout "$now_date|$VD_lead_id| |$AMDSTATUS|$AMDCAUSE|$calleridname|$calleridnum|\n";
|
|
close(Lout);
|
|
}
|
|
if ( ($AMD_LOG == 2) || ($AMD_LOG == 3) )
|
|
{
|
|
if ($AGILOG) {$agi_string = "AMD logging result to DB: $uniqueid $calleridname $VD_lead_id $AMDSTATUS $AMDCAUSE"; &agi_output;}
|
|
$stmtA = "INSERT INTO vicidial_amd_log (uniqueid,lead_id,call_date,caller_code,channel,server_ip,AMDSTATUS,AMDRESPONSE,AMDCAUSE,run_time,AMDSTATS) values('$uniqueid','$VD_lead_id','$now_date','$calleridname','$channel','$VARserver_ip','$AMDSTATUS','$AMDRESPONSE','$AMDCAUSE','$run_time','$AMDSTATS')";
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
$affected_rows = $dbhA->do($stmtA);
|
|
}
|
|
|
|
|
|
##################################################################################
|
|
########## AMD says it's a person so exit and go on to transfer scripts ##########
|
|
if ( ($AMDSTATUS =~ /PERSON|HUMAN|NOTSURE|HANGUP/) && ($force_playback !~ /YES/) )
|
|
{
|
|
if ($A)
|
|
{
|
|
if ($AGILOG) {$agi_string = " AMD exiting"; &agi_output;}
|
|
}
|
|
exit;
|
|
}
|
|
|
|
else
|
|
{
|
|
################################################################################
|
|
########## AMD says it's a machine so modify statuses and hangup call ##########
|
|
########## or play back a message on AMs ##########
|
|
|
|
$AGI->stream_file('sip-silence');
|
|
$AGI->stream_file('sip-silence');
|
|
|
|
|
|
########## FIND vicidial_auto_calls record ##########
|
|
$stmtA = "SELECT campaign_id,phone_code,phone_number,uniqueid,server_ip,status FROM vicidial_auto_calls where callerid='$callerid' order by auto_call_id desc limit 1;";
|
|
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
|
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
|
$sthArows=$sthA->rows;
|
|
if ($AGILOG) {$agi_string = "$sthArows|$stmtA|"; &agi_output;}
|
|
if ($sthArows > 0)
|
|
{
|
|
@aryA = $sthA->fetchrow_array;
|
|
$VD_campaign_id = $aryA[0];
|
|
$VD_phone_code = $aryA[1];
|
|
$VD_phone_number = $aryA[2];
|
|
$VD_uniqueid = $aryA[3];
|
|
$VD_server_ip = $aryA[4];
|
|
$VD_status = $aryA[5];
|
|
$sthA->finish();
|
|
}
|
|
else
|
|
{
|
|
########## FIND vicidial_log_extended record if no vicidial_auto_calls record found ##########
|
|
$stmtA = "SELECT uniqueid,server_ip FROM vicidial_log_extended where caller_code='$callerid' order by call_date desc limit 1;";
|
|
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
|
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
|
$sthArows=$sthA->rows;
|
|
if ($AGILOG) {$agi_string = "$sthArows|$stmtA|"; &agi_output;}
|
|
if ($sthArows > 0)
|
|
{
|
|
@aryA = $sthA->fetchrow_array;
|
|
$VD_uniqueid = $aryA[0];
|
|
$VD_server_ip = $aryA[1];
|
|
$sthA->finish();
|
|
}
|
|
}
|
|
if ( (length($CLIcampaign_id) > 1) && (length($VD_campaign_id) < 1) )
|
|
{$VD_campaign_id = $CLIcampaign_id;}
|
|
if ( (length($CLIphone_code) > 1) && (length($VD_phone_code) < 1) )
|
|
{$VD_phone_code = $CLIphone_code;}
|
|
if ( (length($CLIphone_number) > 1) && (length($VD_phone_number) < 1) )
|
|
{$VD_phone_number = $CLIphone_number;}
|
|
$VD_uniqueidSQL = '';
|
|
if (length($VD_uniqueid) > 1)
|
|
{
|
|
$EVD_uniqueid = $VD_uniqueid;
|
|
$EVD_uniqueid =~ s/\.\d+$//gi;
|
|
$VD_uniqueidSQL = " or (uniqueid LIKE \"$EVD_uniqueid%\")";
|
|
}
|
|
|
|
if ($AMDSTATUS !~ /CPD/)
|
|
{
|
|
########## UPDATE vicidial_list ##########
|
|
$stmtA = "UPDATE vicidial_list set status='AA' where lead_id = '$VD_lead_id';";
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
$affected_rows = $dbhA->do($stmtA);
|
|
if ($AGILOG) {$agi_string = "-- VDAD vicidial_list update: |$affected_rows|$VD_lead_id"; &agi_output;}
|
|
}
|
|
|
|
### find list_id for this lead
|
|
$stmtA = "SELECT list_id,called_count from vicidial_list where lead_id = '$VD_lead_id';";
|
|
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
|
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
|
$sthArowsL=$sthA->rows;
|
|
if ($sthArowsL > 0)
|
|
{
|
|
@aryA = $sthA->fetchrow_array;
|
|
$VD_list_id = $aryA[0];
|
|
$VD_called_count = $aryA[1];
|
|
}
|
|
$sthA->finish();
|
|
|
|
########## UPDATE vicidial_auto_calls entry ##########
|
|
$stmtA = "UPDATE vicidial_auto_calls set status='XFER' where callerid='$callerid' order by auto_call_id desc limit 1;";
|
|
$affected_rows = $dbhA->do($stmtA);
|
|
if ($AGILOG) {$agi_string = "-- VDAC record updated: |$affected_rows| |$VD_lead_id|$uniqueid|$callerid|$VD_status|$VD_server_ip"; &agi_output;}
|
|
|
|
########## FIND AND UPDATE vicidial_log ##########
|
|
$Euniqueid=$uniqueid;
|
|
$Euniqueid =~ s/\.\d+$//gi;
|
|
$stmtA = "SELECT start_epoch,uniqueid,called_count FROM vicidial_log where lead_id='$VD_lead_id' and ( (uniqueid LIKE \"$Euniqueid%\") $VD_uniqueidSQL ) order by call_date desc limit 10;";
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
|
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
|
$sthArows=$sthA->rows;
|
|
$epc_countCUSTDATA=0;
|
|
$first_uniqueid='';
|
|
while ($sthArows > $epc_countCUSTDATA)
|
|
{
|
|
@aryA = $sthA->fetchrow_array;
|
|
$VD_start_epoch = $aryA[0];
|
|
$uniqueid = $aryA[1];
|
|
$DB_called_count = $aryA[2];
|
|
if ($epc_countCUSTDATA < 1) {$first_uniqueid = $aryA[1];}
|
|
$epc_countCUSTDATA++;
|
|
}
|
|
$sthA->finish();
|
|
|
|
if ($epc_countCUSTDATA > 1)
|
|
{
|
|
$stmtA = "DELETE from vicidial_log where uniqueid='$first_uniqueid' and lead_id='$VD_lead_id' limit 1;";
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
$affected_rows = $dbhA->do($stmtA);
|
|
if ($AGILOG) {$agi_string = "-- VDAD vicidial_log duplicate delete: |$affected_rows|$uniqueid|$first_uniqueid|$VD_lead_id|$DB_called_count|"; &agi_output;}
|
|
}
|
|
|
|
if (!$epc_countCUSTDATA)
|
|
{
|
|
if ($AGILOG) {$agi_string = "no VDL record found: $uniqueid $calleridname $VD_lead_id $uniqueid"; &agi_output;}
|
|
$end_epoch = ($now_date_epoch + 3);
|
|
$stmtA = "INSERT INTO vicidial_log (uniqueid,lead_id,campaign_id,call_date,start_epoch,status,phone_code,phone_number,user,processed,length_in_sec,end_epoch,list_id,called_count) values('$uniqueid','$VD_lead_id','$VD_campaign_id','$now_date','$now_date_epoch','AA','$VD_phone_code','$VD_phone_number','VDAD','N','3','$end_epoch','$VD_list_id','$VD_called_count')";
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
$affected_rows = $dbhA->do($stmtA);
|
|
}
|
|
else
|
|
{
|
|
$VD_seconds = ($now_date_epoch - $VD_start_epoch);
|
|
$stmtA = "UPDATE vicidial_log set status='AA',end_epoch='$now_date_epoch',length_in_sec='$VD_seconds',list_id='$VD_list_id',called_count='$VD_called_count' where uniqueid='$uniqueid' and lead_id='$VD_lead_id' order by call_date desc limit 1;";
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
$affected_rows = $dbhA->do($stmtA);
|
|
if ($AGILOG) {$agi_string = "-- VDAD vicidial_log update: |$affected_rows|$uniqueid|$DB_called_count|$VD_called_count|"; &agi_output;}
|
|
}
|
|
|
|
$selected_campaign='';
|
|
### Grab vmail forward message values from the database
|
|
$stmtA = "SELECT am_message_exten,amd_send_to_vmx,waitforsilence_options,survey_recording,campaign_rec_filename,cpd_amd_action,amd_inbound_group,amd_callmenu,cpd_unknown_action,campaign_id,am_message_wildcards FROM vicidial_campaigns where campaign_id = '$VD_campaign_id' limit 1;";
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
|
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
|
$sthArows=$sthA->rows;
|
|
if ($sthArows > 0)
|
|
{
|
|
@aryA = $sthA->fetchrow_array;
|
|
$DB_am_message_exten = $aryA[0];
|
|
$DB_amd_send_to_vmx = $aryA[1];
|
|
$waitforsilence_options = $aryA[2];
|
|
$survey_recording = $aryA[3];
|
|
$campaign_rec_filename = $aryA[4];
|
|
$cpd_amd_action = $aryA[5];
|
|
$amd_inbound_group = $aryA[6];
|
|
$amd_callmenu = $aryA[7];
|
|
$cpd_unknown_action = $aryA[8];
|
|
$selected_campaign = $aryA[9];
|
|
$am_message_wildcards = $aryA[10];
|
|
$sthA->finish();
|
|
}
|
|
else
|
|
{
|
|
$sthA->finish();
|
|
### Grab vmail forward message values from the database
|
|
$SQL_group_id=$VD_campaign_id; $SQL_group_id =~ s/_/\\_/gi;
|
|
$stmtA = "SELECT am_message_exten,amd_send_to_vmx,waitforsilence_options,survey_recording,campaign_rec_filename,cpd_amd_action,amd_inbound_group,amd_callmenu,cpd_unknown_action,campaign_id,am_message_wildcards FROM vicidial_campaigns where closer_campaigns LIKE \"% $SQL_group_id %\" order by campaign_id limit 1;";
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
|
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
|
$sthArows=$sthA->rows;
|
|
if ($sthArows > 0)
|
|
{
|
|
@aryA = $sthA->fetchrow_array;
|
|
$DB_am_message_exten = $aryA[0];
|
|
$DB_amd_send_to_vmx = $aryA[1];
|
|
$waitforsilence_options = $aryA[2];
|
|
$survey_recording = $aryA[3];
|
|
$campaign_rec_filename = $aryA[4];
|
|
$cpd_amd_action = $aryA[5];
|
|
$amd_inbound_group = $aryA[6];
|
|
$amd_callmenu = $aryA[7];
|
|
$cpd_unknown_action = $aryA[8];
|
|
$selected_campaign = $aryA[9];
|
|
$am_message_wildcards = $aryA[10];
|
|
$sthA->finish();
|
|
if ($AGILOG) {$agi_string = "-- Inbound call, settings gathered from: |$selected_campaign|$DB_am_message_exten|$DB_amd_send_to_vmx|$waitforsilence_options"; &agi_output;}
|
|
}
|
|
else
|
|
{$sthA->finish();}
|
|
}
|
|
|
|
### if not a CPD message, log to the extended log
|
|
if ($AMDSTATUS !~ /CPD/)
|
|
{
|
|
$VLEcount=0;
|
|
$stmtA = "SELECT count(*) FROM vicidial_log_extended where uniqueid='$uniqueid';";
|
|
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
|
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
|
$sthArows=$sthA->rows;
|
|
if ($sthArows > 0)
|
|
{
|
|
@aryA = $sthA->fetchrow_array;
|
|
$VLEcount = $aryA[0];
|
|
$sthA->finish();
|
|
}
|
|
if ($AGILOG) {$agi_string = "$VLEcount|$stmtA|"; &agi_output;}
|
|
|
|
if ($VLEcount < 1)
|
|
{
|
|
$stmtA = "INSERT INTO vicidial_log_extended set uniqueid='$uniqueid',server_ip='$VARserver_ip',call_date='$now_date',lead_id = '$VD_lead_id',caller_code='$callerid',custom_call_id='';";
|
|
$affected_rows = $dbhA->do($stmtA);
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
if ($AGILOG) {$agi_string = "-- VDAD vicidial_log_extended insert: |$affected_rows|\n|$stmtA|"; &agi_output;}
|
|
}
|
|
}
|
|
|
|
if ($survey_recording =~ /Y_WITH_AMD/)
|
|
{
|
|
$RLcount=0;
|
|
if ($AMDSTATUS =~ /CPD/)
|
|
{
|
|
$stmtA = "SELECT count(*) FROM recording_log where vicidial_id='$uniqueid' and lead_id='$VD_lead_id' and user='VDAD';";
|
|
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
|
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
|
$sthArows=$sthA->rows;
|
|
if ($sthArows > 0)
|
|
{
|
|
@aryA = $sthA->fetchrow_array;
|
|
$RLcount = $aryA[0];
|
|
}
|
|
$sthA->finish();
|
|
if ($AGILOG) {$agi_string = "$RLcount|$stmtA|"; &agi_output;}
|
|
}
|
|
if ($RLcount < 1)
|
|
{
|
|
# get date/time
|
|
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
|
|
$year = ($year + 1900);
|
|
$Tyear = ($year - 2000);
|
|
$mon++;
|
|
if ($mon < 10) {$mon = "0$mon";}
|
|
if ($mday < 10) {$mday = "0$mday";}
|
|
if ($hour < 10) {$hour = "0$hour";}
|
|
if ($min < 10) {$min = "0$min";}
|
|
if ($sec < 10) {$sec = "0$sec";}
|
|
|
|
$now_date_epoch = time();
|
|
$now_date = "$year-$mon-$mday $hour:$min:$sec";
|
|
$recdate = "$year$mon$mday-$hour$min$sec";
|
|
$tinydate = "$Tyear$mon$mday$hour$min$sec";
|
|
|
|
if ($campaign_rec_filename =~ /VENDORLEADCODE/)
|
|
{
|
|
$stmtA = "SELECT vendor_lead_code FROM vicidial_list where lead_id='$VD_lead_id';";
|
|
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
|
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
|
$sthArows=$sthA->rows;
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
if ($sthArows > 0)
|
|
{
|
|
@aryA = $sthA->fetchrow_array;
|
|
$vendor_lead_code = $aryA[0];
|
|
}
|
|
$sthA->finish();
|
|
}
|
|
|
|
$campaign_rec_filename =~ s/CAMPAIGN/$VD_campaign_id/gi;
|
|
$campaign_rec_filename =~ s/INGROUP/$VD_campaign_id/gi;
|
|
$campaign_rec_filename =~ s/CUSTPHONE/$VD_phone_number/gi;
|
|
$campaign_rec_filename =~ s/FULLDATE/$recdate/gi;
|
|
$campaign_rec_filename =~ s/TINYDATE/$tinydate/gi;
|
|
$campaign_rec_filename =~ s/EPOCH/$now_date_epoch/gi;
|
|
$campaign_rec_filename =~ s/AGENT/VDAD/gi;
|
|
$campaign_rec_filename =~ s/VENDORLEADCODE/$vendor_lead_code/gi;
|
|
$campaign_rec_filename =~ s/LEADID/$VD_lead_id/gi;
|
|
$campaign_rec_filename =~ s/CALLID/$callerid/gi;
|
|
$campaign_rec_filename =~ s/\"|\'//gi;
|
|
$campaign_rec_filename =~ s/ //gi;
|
|
|
|
%ast_ver_str = parse_asterisk_version($asterisk_version);
|
|
if (( $ast_ver_str{major} = 1 ) && ($ast_ver_str{minor} < 6))
|
|
{
|
|
$AGI->exec("Monitor wav|/var/spool/asterisk/monitor/MIX/$campaign_rec_filename");
|
|
}
|
|
else
|
|
{
|
|
$AGI->exec("Monitor","wav,/var/spool/asterisk/monitor/MIX/$campaign_rec_filename");
|
|
}
|
|
|
|
### insert record into recording_log table ###
|
|
$stmtA = "INSERT INTO recording_log (channel,server_ip,extension,start_time,start_epoch,length_in_sec,filename,lead_id,user,location,vicidial_id) values('$channel','$VARserver_ip','$VD_phone_number','$now_date','$now_date_epoch','0','$campaign_rec_filename','$VD_lead_id','VDAD','$campaign_rec_filename','$uniqueid');";
|
|
$SRaffected_rows = $dbhA->do($stmtA);
|
|
if ($AGILOG) {$agi_string = "-- AMD RECORDING STARTED : |$SRaffected_rows|$campaign_rec_filename|$stmtA|"; &agi_output;}
|
|
}
|
|
}
|
|
|
|
### check for list_id override
|
|
if ( ( ($DB_amd_send_to_vmx =~ /Y/) || ($AMDSTATUS =~ /CPD/) ) && ($AMDCAUSE !~ /^Unknown|\?\?\?/i) )
|
|
{
|
|
$am_message_exten_override='';
|
|
### gather list_id overrides
|
|
$stmtA = "SELECT am_message_exten_override FROM vicidial_lists where list_id='$VD_list_id';";
|
|
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
|
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
|
$sthArowsL=$sthA->rows;
|
|
if ($sthArowsL > 0)
|
|
{
|
|
@aryA = $sthA->fetchrow_array;
|
|
$am_message_exten_override = $aryA[0];
|
|
if (length($am_message_exten_override) > 0)
|
|
{$DB_am_message_exten = $am_message_exten_override;}
|
|
}
|
|
$sthA->finish();
|
|
}
|
|
|
|
if ($AGILOG) {$agi_string = "-- AMD campaign values: |$VD_campaign_id|$DB_am_message_exten|$DB_amd_send_to_vmx|"; &agi_output;}
|
|
|
|
if ( ( ($DB_amd_send_to_vmx =~ /Y/) || ($force_playback =~ /YES/) ) && (length($DB_am_message_exten) > 0) )
|
|
{
|
|
$msg_status='AM';
|
|
if ($AMDCAUSE =~ /^Unknown|\?\?\?/i)
|
|
{$msg_status='UNKAM';}
|
|
|
|
$stmtA = "UPDATE vicidial_log set status='$msg_status' where uniqueid='$uniqueid' and lead_id='$VD_lead_id' order by call_date desc limit 1;";
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
$affected_rows = $dbhA->do($stmtA);
|
|
if ($AGILOG) {$agi_string = "-- VDAD vicidial_log AM update: |$affected_rows|$uniqueid|"; &agi_output;}
|
|
|
|
$stmtA = "UPDATE vicidial_list set status='$msg_status' where lead_id='$VD_lead_id';";
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
$affected_rows = $dbhA->do($stmtA);
|
|
if ($AGILOG) {$agi_string = "-- VDAD vicidial_list AM update: |$affected_rows|$uniqueid|"; &agi_output;}
|
|
|
|
|
|
##### BEGIN Check if prompt uses TTS or DYN, if so, create TTS and set the filename to the generated prompt #####
|
|
if ( ($DB_am_message_exten =~ /^TTS/) || ($DB_am_message_exten =~ /^DYN/) )
|
|
{
|
|
$useTTS=0;
|
|
if ($DB_am_message_exten =~ /^TTS/)
|
|
{$useTTS++;}
|
|
$TTS_filename = $DB_am_message_exten;
|
|
$TTS_filename =~s/^TTS|^DYN//gi;
|
|
$TTS_filename =~s/\|.*//gi;
|
|
|
|
if ($AGILOG) {$agi_string = "-- TTS : |$useTTS|$TTS_filename|"; &agi_output;}
|
|
|
|
$stmtA = "SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner FROM vicidial_list where lead_id='$VD_lead_id';";
|
|
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
|
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
|
$sthArows=$sthA->rows;
|
|
if ($sthArows > 0)
|
|
{
|
|
@aryA = $sthA->fetchrow_array;
|
|
$TTS_lead_id = $aryA[0];
|
|
$TTS_entry_date = $aryA[1];
|
|
$TTS_modify_date = $aryA[2];
|
|
$TTS_status = $aryA[3];
|
|
$TTS_user = $aryA[4];
|
|
$TTS_vendor_lead_code = $aryA[5];
|
|
$TTS_source_id = $aryA[6];
|
|
$TTS_list_id = $aryA[7];
|
|
$TTS_phone_number = $aryA[8];
|
|
$TTS_title = $aryA[9];
|
|
$TTS_first_name = $aryA[10];
|
|
$TTS_middle_initial = $aryA[11];
|
|
$TTS_last_name = $aryA[12];
|
|
$TTS_address1 = $aryA[13];
|
|
$TTS_address2 = $aryA[14];
|
|
$TTS_address3 = $aryA[15];
|
|
$TTS_city = $aryA[16];
|
|
$TTS_state = $aryA[17];
|
|
$TTS_province = $aryA[18];
|
|
$TTS_postal_code = $aryA[19];
|
|
$TTS_country_code = $aryA[20];
|
|
$TTS_gender = $aryA[21];
|
|
$TTS_date_of_birth = $aryA[22];
|
|
$TTS_alt_phone = $aryA[23];
|
|
$TTS_email = $aryA[24];
|
|
$TTS_security_phrase = $aryA[25];
|
|
$TTS_comments = $aryA[26];
|
|
$TTS_called_count = $aryA[27];
|
|
$TTS_last_local_call_time = $aryA[28];
|
|
$TTS_rank = $aryA[29];
|
|
$TTS_owner = $aryA[30];
|
|
}
|
|
$sthA->finish();
|
|
|
|
$TTS_voice = 'Allison-8kHz';
|
|
$TTS_text = $TTS_filename;
|
|
$stmtA = "SELECT tts_text,tts_voice FROM vicidial_tts_prompts where tts_id='$TTS_filename';";
|
|
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
|
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
|
$sthArows=$sthA->rows;
|
|
if ($sthArows > 0)
|
|
{
|
|
@aryA = $sthA->fetchrow_array;
|
|
$TTS_voice = $aryA[1];
|
|
$TTS_text = $aryA[0];
|
|
}
|
|
$sthA->finish();
|
|
|
|
### BEGIN replace variables with record values ###
|
|
$TTS_text =~ s/--A--lead_id--B--/$TTS_lead_id/gi;
|
|
$TTS_text =~ s/--A--entry_date--B--/$TTS_entry_date/gi;
|
|
$TTS_text =~ s/--A--modify_date--B--/$TTS_modify_date/gi;
|
|
$TTS_text =~ s/--A--status--B--/$TTS_status/gi;
|
|
$TTS_text =~ s/--A--user--B--/$TTS_user/gi;
|
|
$TTS_text =~ s/--A--vendor_lead_code--B--/$TTS_vendor_lead_code/gi;
|
|
$TTS_text =~ s/--A--source_id--B--/$TTS_source_id/gi;
|
|
$TTS_text =~ s/--A--list_id--B--/$TTS_list_id/gi;
|
|
$TTS_text =~ s/--A--phone_number--B--/$TTS_phone_number/gi;
|
|
$TTS_text =~ s/--A--title--B--/$TTS_title/gi;
|
|
$TTS_text =~ s/--A--first_name--B--/$TTS_first_name/gi;
|
|
$TTS_text =~ s/--A--middle_initial--B--/$TTS_middle_initial/gi;
|
|
$TTS_text =~ s/--A--last_name--B--/$TTS_last_name/gi;
|
|
$TTS_text =~ s/--A--address1--B--/$TTS_address1/gi;
|
|
$TTS_text =~ s/--A--address2--B--/$TTS_address2/gi;
|
|
$TTS_text =~ s/--A--address3--B--/$TTS_address3/gi;
|
|
$TTS_text =~ s/--A--city--B--/$TTS_city/gi;
|
|
$TTS_text =~ s/--A--state--B--/$TTS_state/gi;
|
|
$TTS_text =~ s/--A--province--B--/$TTS_province/gi;
|
|
$TTS_text =~ s/--A--postal_code--B--/$TTS_postal_code/gi;
|
|
$TTS_text =~ s/--A--country_code--B--/$TTS_country_code/gi;
|
|
$TTS_text =~ s/--A--gender--B--/$TTS_gender/gi;
|
|
$TTS_text =~ s/--A--date_of_birth--B--/$TTS_date_of_birth/gi;
|
|
$TTS_text =~ s/--A--alt_phone--B--/$TTS_alt_phone/gi;
|
|
$TTS_text =~ s/--A--email--B--/$TTS_email/gi;
|
|
$TTS_text =~ s/--A--security_phrase--B--/$TTS_security_phrase/gi;
|
|
$TTS_text =~ s/--A--comments--B--/$TTS_comments/gi;
|
|
$TTS_text =~ s/--A--called_count--B--/$TTS_called_count/gi;
|
|
$TTS_text =~ s/--A--last_local_call_time--B--/$TTS_last_local_call_time/gi;
|
|
$TTS_text =~ s/--A--rank--B--/$TTS_rank/gi;
|
|
$TTS_text =~ s/--A--owner--B--/$TTS_owner/gi;
|
|
$TTS_text =~ s/--A--campaign_id--B--/$VD_campaign_id/gi;
|
|
$TTS_text =~ s/--A--ingroup--B--/$VD_campaign_id/gi;
|
|
$TTS_text =~ s/--A--group--B--/$VD_campaign_id/gi;
|
|
### END replace variables with record values ###
|
|
|
|
if ($useTTS > 0)
|
|
{
|
|
### BEGIN check for --C-- and --D-- tags for static file replacement
|
|
if ( ($TTS_text =~ /--C--/) || ($TTS_text =~ /--D--/) )
|
|
{
|
|
$Cdash='--C--';
|
|
$Ddash='--D--';
|
|
@static_check = split(/--C--/,$TTS_text);
|
|
$sc=0;
|
|
$sr=0;
|
|
foreach(@static_check)
|
|
{
|
|
if ($sc > 0)
|
|
{
|
|
$static_check[$sc] =~ s/--D-.*//gi;
|
|
$static_check_lc = lc($static_check[$sc]);
|
|
print STDERR " Checking For Static Replacement: $static_check[$sc]|$static_check_lc$wav\n";
|
|
$static_found=0;
|
|
if (-e "/var/lib/asterisk/sounds/tts_static/$static_check_lc$wav")
|
|
{
|
|
$CDstatic = "<audio src='/var/lib/asterisk/sounds/tts_static/$static_check_lc$wav' /> ";
|
|
$static_found++;
|
|
}
|
|
else
|
|
{
|
|
if (-e "/var/lib/asterisk/sounds/$static_check_lc$wav")
|
|
{
|
|
$CDstatic = "<audio src='/var/lib/asterisk/sounds/$static_check_lc$wav' /> ";
|
|
$static_found++;
|
|
}
|
|
else
|
|
{
|
|
$firsttwo = substr($static_check_lc, 0, 2);
|
|
if (-e "/var/lib/asterisk/sounds/tts_static/$firsttwo/$static_check_lc$wav")
|
|
{
|
|
$CDstatic = "<audio src='/var/lib/asterisk/sounds/tts_static/$firsttwo/$static_check_lc$wav' /> ";
|
|
$static_found++;
|
|
}
|
|
}
|
|
}
|
|
if ($static_found > 0)
|
|
{
|
|
$CDmatch = "$Cdash$static_check[$sc]$Ddash";
|
|
$TTS_text =~ s/$CDmatch/$CDstatic/gi;
|
|
print STDERR " Static Replacement Found: $CDmatch|$CDstatic\n";
|
|
$sr++;
|
|
}
|
|
}
|
|
$sc++;
|
|
}
|
|
$TTS_text =~ s/--C--|--D--//gi;
|
|
print STDERR "\nStatic Replacements Found: $sc|$sr\n";
|
|
}
|
|
### END check for --C-- and --D-- tags for static file replacement
|
|
|
|
### filter input for CLI-safe characters
|
|
$TTS_text =~ s/[^,\.\<\>\'\/\=\_\-\: 0-9a-zA-Z]//gi;
|
|
$TTS_textRAW = $TTS_text;
|
|
$TTS_text =~ s/ /\\ /gi;
|
|
$TTS_text =~ s/\./\\./gi;
|
|
$TTS_text =~ s/\=/\\=/gi;
|
|
$TTS_text =~ s/\</\\</gi;
|
|
$TTS_text =~ s/\>/\\>/gi;
|
|
$TTS_text =~ s/\//\\\//gi;
|
|
$TTS_text =~ s/\'/\\'/gi;
|
|
# $voice = 'Allison-8kHz'; # override the voice to Allison-8k
|
|
print STDERR "\nGenerating: $TTS_text - $TTS_voice\n";
|
|
|
|
### send command to generate cepstral TTS audio file
|
|
`$PATHagi/cepstral_generate.pl --debug --voice=$TTS_voice --dialog=$TTS_text >> $CEPLOGfile `;
|
|
|
|
use Digest::MD5 qw(md5_hex);
|
|
|
|
$enc = md5_hex("$TTS_textRAW-$TTS_voice"); # the hash
|
|
$enc_ftl = substr($enc, 0, 2); # first letter of hash
|
|
$TTS_filename_path = $PATHsounds . "/tts/" . $enc_ftl . "/tts-" . $enc;
|
|
}
|
|
else
|
|
{$TTS_filename_path = $TTS_text;}
|
|
print STDERR "\nfilename: $TTS_filename_path\n";
|
|
|
|
$DB_am_message_exten = $TTS_filename_path;
|
|
}
|
|
##### END Check if prompt uses TTS, if so, create TTS and set the filename to the generated prompt #####
|
|
|
|
|
|
|
|
### BEGIN am message wildcards ###
|
|
if ($am_message_wildcards =~ /Y/)
|
|
{
|
|
$stmtA = "SELECT count(*) FROM vicidial_amm_multi where campaign_id='$selected_campaign' and active='Y';";
|
|
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
|
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
|
$sthArowsW=$sthA->rows;
|
|
$sthA->finish();
|
|
if ($sthArowsW > 0)
|
|
{
|
|
$stmtA = "SELECT lead_id,entry_date,modify_date,status,user,vendor_lead_code,source_id,list_id,phone_number,title,first_name,middle_initial,last_name,address1,address2,address3,city,state,province,postal_code,country_code,gender,date_of_birth,alt_phone,email,security_phrase,comments,called_count,last_local_call_time,rank,owner FROM vicidial_list where lead_id='$VD_lead_id';";
|
|
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
|
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
|
$sthArows=$sthA->rows;
|
|
if ($sthArows > 0)
|
|
{
|
|
@aryA = $sthA->fetchrow_array;
|
|
$AMM_lead_id = $aryA[0];
|
|
$AMM_entry_date = $aryA[1];
|
|
$AMM_modify_date = $aryA[2];
|
|
$AMM_status = $aryA[3];
|
|
$AMM_user = $aryA[4];
|
|
$AMM_vendor_lead_code = $aryA[5];
|
|
$AMM_source_id = $aryA[6];
|
|
$AMM_list_id = $aryA[7];
|
|
$AMM_phone_number = $aryA[8];
|
|
$AMM_title = $aryA[9];
|
|
$AMM_first_name = $aryA[10];
|
|
$AMM_middle_initial = $aryA[11];
|
|
$AMM_last_name = $aryA[12];
|
|
$AMM_address1 = $aryA[13];
|
|
$AMM_address2 = $aryA[14];
|
|
$AMM_address3 = $aryA[15];
|
|
$AMM_city = $aryA[16];
|
|
$AMM_state = $aryA[17];
|
|
$AMM_province = $aryA[18];
|
|
$AMM_postal_code = $aryA[19];
|
|
$AMM_country_code = $aryA[20];
|
|
$AMM_gender = $aryA[21];
|
|
$AMM_date_of_birth = $aryA[22];
|
|
$AMM_alt_phone = $aryA[23];
|
|
$AMM_email = $aryA[24];
|
|
$AMM_security_phrase = $aryA[25];
|
|
$AMM_comments = $aryA[26];
|
|
$AMM_called_count = $aryA[27];
|
|
$AMM_last_local_call_time = $aryA[28];
|
|
$AMM_rank = $aryA[29];
|
|
$AMM_owner = $aryA[30];
|
|
}
|
|
$sthA->finish();
|
|
|
|
$stmtA = "SELECT amm_field,amm_rank,amm_wildcard,amm_filename FROM vicidial_amm_multi where campaign_id='$selected_campaign' and active='Y' order by amm_rank,amm_field;";
|
|
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
|
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
|
|
$sthArowsA=$sthA->rows;
|
|
$w=0;
|
|
$amm_filename_match='';
|
|
while ( ($sthArowsA > $w) && (length($amm_filename_match) < 1) )
|
|
{
|
|
@aryA = $sthA->fetchrow_array;
|
|
$amm_field = $aryA[0];
|
|
$amm_rank = $aryA[1];
|
|
$amm_wildcard = $aryA[2];
|
|
$amm_filename = $aryA[3];
|
|
|
|
if ( (length($amm_wildcard)>0) && (length($amm_wildcard)>0) && (length($amm_filename)>0) )
|
|
{
|
|
if ($amm_field =~ /vendor_lead_code/)
|
|
{
|
|
if ($AMM_vendor_lead_code =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM vendor_lead_code Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_vendor_lead_code)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /source_id/)
|
|
{
|
|
if ($AMM_source_id =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM source_id Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_source_id)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /list_id/)
|
|
{
|
|
if ($AMM_list_id =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM list_id Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_list_id)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /phone_number/)
|
|
{
|
|
if ($AMM_phone_number =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM phone_number Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_phone_number)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /title/)
|
|
{
|
|
if ($AMM_title =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM title Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_title)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /first_name/)
|
|
{
|
|
if ($AMM_first_name =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM first_name Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_first_name)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /middle_initial/)
|
|
{
|
|
if ($AMM_middle_initial =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM middle_initial Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_middle_initial)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /last_name/)
|
|
{
|
|
if ($AMM_last_name =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM last_name Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_last_name)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /address1/)
|
|
{
|
|
if ($AMM_address1 =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM address1 Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_address1)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /address2/)
|
|
{
|
|
if ($AMM_address2 =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM address2 Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_address2)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /address3/)
|
|
{
|
|
if ($AMM_address3 =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM address3 Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_address3)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /city/)
|
|
{
|
|
if ($AMM_city =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM city Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_city)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /state/)
|
|
{
|
|
if ($AMM_state =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM state Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_state)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /province/)
|
|
{
|
|
if ($AMM_province =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM province Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_province)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /postal_code/)
|
|
{
|
|
if ($AMM_postal_code =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM postal_code Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_postal_code)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /country_code/)
|
|
{
|
|
if ($AMM_country_code =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM country_code Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_country_code)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /gender/)
|
|
{
|
|
if ($AMM_gender =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM gender Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_gender)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /date_of_birth/)
|
|
{
|
|
if ($AMM_date_of_birth =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM date_of_birth Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_date_of_birth)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /alt_phone/)
|
|
{
|
|
if ($AMM_alt_phone =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM alt_phone Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_alt_phone)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /email/)
|
|
{
|
|
if ($AMM_email =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM email Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_email)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /security_phrase/)
|
|
{
|
|
if ($AMM_security_phrase =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM security_phrase Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_security_phrase)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /comments/)
|
|
{
|
|
if ($AMM_comments =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM comments Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_comments)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /rank/)
|
|
{
|
|
if ($AMM_rank =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM rank Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_rank)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /owner/)
|
|
{
|
|
if ($AMM_owner =~ /$amm_wildcard/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM owner Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_owner)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
if ($amm_field =~ /called_count/)
|
|
{
|
|
if ($AMM_called_count =~ /^$amm_wildcard$/i)
|
|
{
|
|
$amm_filename_match = $amm_filename;
|
|
if ($AGILOG) {$agi_string = "AMM called_count Match Found: |$amm_field|$amm_rank|$amm_wildcard($AMM_owner)|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
|
|
if (length($amm_filename_match) > 0)
|
|
{$DB_am_message_exten = $amm_filename_match;}
|
|
else
|
|
{
|
|
if ($AGILOG) {$agi_string = "no AMM match: |$amm_field|$amm_rank|$amm_wildcard|$amm_filename|"; &agi_output;}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ($AGILOG) {$agi_string = "AMM entry invalid: |$amm_field|$amm_rank|$amm_wildcard|$amm_filename|"; &agi_output;}
|
|
}
|
|
$w++;
|
|
}
|
|
$sthA->finish();
|
|
}
|
|
}
|
|
### END am message wildcards ###
|
|
|
|
|
|
### run waitforsilence if enabled
|
|
if ($AMDCAUSE !~ /^Unknown|\?\?\?/i)
|
|
{
|
|
if ( (length($waitforsilence_options) > 0) && ($waitforsilence_options !~ /NONE|X/i) )
|
|
{
|
|
if ($AGILOG) {$agi_string = "WaitForSilence launched: |$waitforsilence_options|"; &agi_output;}
|
|
$AGI->exec("WaitForSilence","$waitforsilence_options");
|
|
}
|
|
if ($waitforsilence_options =~ /X/i)
|
|
{
|
|
$waitforsilence_seconds = $waitforsilence_options;
|
|
$waitforsilence_seconds =~ s/\D//gi;
|
|
if (length($waitforsilence_seconds) < 1)
|
|
{$waitforsilence_seconds = '1';}
|
|
if ($waitforsilence_seconds > 20)
|
|
{$waitforsilence_seconds = '20';}
|
|
if ($AGILOG) {$agi_string = "Wait time seconds in WaitForSilence field: |$waitforsilence_seconds|$waitforsilence_options|"; &agi_output;}
|
|
sleep($waitforsilence_seconds);
|
|
}
|
|
}
|
|
|
|
### if call menu or in-group method
|
|
if ( ($AMDCAUSE =~ /^Unknown|\?\?\?/i) && ($cpd_unknown_action =~ /CALLMENU|INGROUP/) )
|
|
{
|
|
$DROPexten='';
|
|
if ($cpd_unknown_action =~ /CALLMENU/)
|
|
{
|
|
$DROPexten = 's';
|
|
$ext_context = $amd_callmenu;
|
|
}
|
|
if ($cpd_unknown_action =~ /INGROUP/)
|
|
{ # 90009*CL_uk3survy_*8301*10000123*universal*7275551212*1234*"
|
|
$S='*';
|
|
$fronter='VDAMD';
|
|
$DROPexten = "90009*$amd_inbound_group$S$S$VD_lead_id$S$S$VD_phone_number$S$fronter$S";
|
|
}
|
|
if (length($DROPexten)>0)
|
|
{
|
|
$stmtA = "UPDATE vicidial_log set status='UNKXFR' where uniqueid='$uniqueid' and lead_id='$VD_lead_id' order by call_date desc limit 1;";
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
$affected_rows = $dbhA->do($stmtA);
|
|
if ($AGILOG) {$agi_string = "-- VDAD vicidial_log UNKXFR update: |$affected_rows|$uniqueid|"; &agi_output;}
|
|
|
|
$stmtA = "UPDATE vicidial_list set status='UNKXFR' where lead_id='$VD_lead_id';";
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
$affected_rows = $dbhA->do($stmtA);
|
|
if ($AGILOG) {$agi_string = "-- VDAD vicidial_list UNKXFR update: |$affected_rows|$uniqueid|"; &agi_output;}
|
|
|
|
$AGI->stream_file('sip-silence');
|
|
$AGI->stream_file('sip-silence');
|
|
$AGI->stream_file('sip-silence');
|
|
$AGI->stream_file('sip-silence');
|
|
|
|
if ($AGILOG) {$agi_string = "exiting the VD_AMD app CPD Unknown, transferring call to $DROPexten:$ext_context"; &agi_output;}
|
|
print "SET CONTEXT $ext_context\n";
|
|
$result = <STDIN>;
|
|
checkresult($result);
|
|
print "SET EXTENSION $DROPexten\n";
|
|
$result = <STDIN>;
|
|
checkresult($result);
|
|
print "SET PRIORITY 1\n";
|
|
$result = <STDIN>;
|
|
checkresult($result);
|
|
|
|
exit;
|
|
}
|
|
}
|
|
|
|
if ( ($AMDCAUSE !~ /^Unknown|\?\?\?/i) && ($cpd_amd_action =~ /CALLMENU|INGROUP/) )
|
|
{
|
|
$DROPexten='';
|
|
if ($cpd_amd_action =~ /CALLMENU/)
|
|
{
|
|
$DROPexten = 's';
|
|
$ext_context = $amd_callmenu;
|
|
}
|
|
if ($cpd_amd_action =~ /INGROUP/)
|
|
{ # 90009*CL_uk3survy_*8301*10000123*universal*7275551212*1234*"
|
|
$S='*';
|
|
$fronter='VDAMD';
|
|
$DROPexten = "90009*$amd_inbound_group$S$S$VD_lead_id$S$S$VD_phone_number$S$fronter$S";
|
|
}
|
|
if (length($DROPexten)>0)
|
|
{
|
|
$stmtA = "UPDATE vicidial_log set status='AMDXFR' where uniqueid='$uniqueid' and lead_id='$VD_lead_id' order by call_date desc limit 1;";
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
$affected_rows = $dbhA->do($stmtA);
|
|
if ($AGILOG) {$agi_string = "-- VDAD vicidial_log AMDXFR update: |$affected_rows|$uniqueid|"; &agi_output;}
|
|
|
|
$stmtA = "UPDATE vicidial_list set status='AMDXFR' where lead_id='$VD_lead_id';";
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
$affected_rows = $dbhA->do($stmtA);
|
|
if ($AGILOG) {$agi_string = "-- VDAD vicidial_list AMDXFR update: |$affected_rows|$uniqueid|"; &agi_output;}
|
|
|
|
$AGI->stream_file('sip-silence');
|
|
$AGI->stream_file('sip-silence');
|
|
$AGI->stream_file('sip-silence');
|
|
$AGI->stream_file('sip-silence');
|
|
|
|
if ($AGILOG) {$agi_string = "exiting the VD_AMD app, transferring call to $DROPexten:$ext_context"; &agi_output;}
|
|
print "SET CONTEXT $ext_context\n";
|
|
$result = <STDIN>;
|
|
checkresult($result);
|
|
print "SET EXTENSION $DROPexten\n";
|
|
$result = <STDIN>;
|
|
checkresult($result);
|
|
print "SET PRIORITY 1\n";
|
|
$result = <STDIN>;
|
|
checkresult($result);
|
|
|
|
exit;
|
|
}
|
|
}
|
|
|
|
|
|
### play messages
|
|
if ($DB_am_message_exten =~ /\|/)
|
|
{
|
|
@DB_am_message_exten_array = split(/\|/,$DB_am_message_exten);
|
|
$w=0;
|
|
foreach(@DB_am_message_exten_array)
|
|
{
|
|
if (length($DB_am_message_exten_array[$w])>0)
|
|
{
|
|
$AGI->stream_file("$DB_am_message_exten_array[$w]");
|
|
}
|
|
$w++;
|
|
}
|
|
}
|
|
else
|
|
{$AGI->stream_file("$DB_am_message_exten");}
|
|
|
|
$last_status='AL';
|
|
if ($AMDCAUSE =~ /^Unknown|\?\?\?/i)
|
|
{$last_status='UNKAL';}
|
|
$stmtA = "UPDATE vicidial_log set status='$last_status' where uniqueid='$uniqueid' and lead_id='$VD_lead_id' order by call_date desc limit 1;";
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
$affected_rows = $dbhA->do($stmtA);
|
|
if ($AGILOG) {$agi_string = "-- VDAD vicidial_log AL update: |$affected_rows|$uniqueid|"; &agi_output;}
|
|
|
|
$stmtA = "UPDATE vicidial_list set status='$last_status' where lead_id='$VD_lead_id';";
|
|
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
|
|
$affected_rows = $dbhA->do($stmtA);
|
|
if ($AGILOG) {$agi_string = "-- VDAD vicidial_list AL update: |$affected_rows|$uniqueid|"; &agi_output;}
|
|
}
|
|
|
|
|
|
$dbhA->disconnect();
|
|
|
|
$AGI->hangup($channel);
|
|
|
|
exit;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
exit;
|
|
|
|
sub checkresult
|
|
{
|
|
my ($res) = @_;
|
|
my $retval;
|
|
$tests++;
|
|
chomp $res;
|
|
if ($res =~ /^200/)
|
|
{
|
|
$res =~ /result=(-?\d+)/;
|
|
if (!length($1))
|
|
{
|
|
# print STDERR "FAIL ($res)\n";
|
|
$fail++;
|
|
}
|
|
else
|
|
{
|
|
# print STDERR "PASS ($1)\n";
|
|
$pass++;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
# print STDERR "FAIL (unexpected result '$res')\n";
|
|
$fail++;
|
|
}
|
|
}
|
|
|
|
|
|
sub agi_output
|
|
{
|
|
if ($AGILOG >=2)
|
|
{
|
|
### open the log file for writing ###
|
|
open(Lout, ">>$AGILOGfile")
|
|
|| die "Can't open $AGILOGfile: $!\n";
|
|
print Lout "$now_date|$script|$agi_string\n";
|
|
close(Lout);
|
|
}
|
|
### send to STDERR writing ###
|
|
if ( ($AGILOG == '1') || ($AGILOG == '3') )
|
|
{print STDERR "$now_date|$script|$agi_string\n";}
|
|
$agi_string='';
|
|
}
|
|
|
|
# subroutine to parse the asterisk version
|
|
# and return a hash with the various part
|
|
sub parse_asterisk_version
|
|
{
|
|
# grab the arguments
|
|
my $ast_ver_str = $_[0];
|
|
|
|
# get everything after the - and put it in $ast_ver_postfix
|
|
my @hyphen_parts = split( /-/ , $ast_ver_str );
|
|
|
|
my $ast_ver_postfix = $hyphen_parts[1];
|
|
|
|
# now split everything before the - up by the .
|
|
my @dot_parts = split( /\./ , $hyphen_parts[0] );
|
|
|
|
my %ast_ver_hash;
|
|
|
|
if ( $dot_parts[0] <= 1 )
|
|
{
|
|
%ast_ver_hash = (
|
|
"major" => $dot_parts[0],
|
|
"minor" => $dot_parts[1],
|
|
"build" => $dot_parts[2],
|
|
"revision" => $dot_parts[3],
|
|
"postfix" => $ast_ver_postfix
|
|
);
|
|
}
|
|
|
|
# digium dropped the 1 from asterisk 10 but we still need it
|
|
if ( $dot_parts[0] > 1 )
|
|
{
|
|
%ast_ver_hash = (
|
|
"major" => 1,
|
|
"minor" => $dot_parts[0],
|
|
"build" => $dot_parts[1],
|
|
"revision" => $dot_parts[2],
|
|
"postfix" => $ast_ver_postfix
|
|
);
|
|
}
|
|
|
|
return ( %ast_ver_hash );
|
|
}
|