1.1.10 release
git-svn-id: svn://192.168.202.10@1 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -0,0 +1,239 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# VD_amd_post.agi version 0.1
|
||||
#
|
||||
# NOTE: This script is only needed with app_amd enabled systems
|
||||
#
|
||||
# runs after a call goes through AMD in extensions.conf to send the call on to
|
||||
# it's proper destination
|
||||
#
|
||||
# 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.agi,${EXTEN})
|
||||
# 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
|
||||
#
|
||||
#
|
||||
# Copyright (C) 2006 Matt Florell <vicidial@gmail.com> LICENSE: GPLv2
|
||||
#
|
||||
# changes:
|
||||
# 60217-1119 first build
|
||||
#
|
||||
|
||||
$V = 0; # set to 1 for verbose mode
|
||||
$M = 0; # set to 1 for 2 line messages mode
|
||||
$A = 1; # set to 1 for AMD output messages mode
|
||||
$AMD_LOG = 0; # set to 1 for logfile
|
||||
|
||||
### Make sure this file is in a path or put the absolute path to it
|
||||
require("/home/cron/AST_SERVER_conf.pl"); # local configuration file
|
||||
|
||||
use Net::MySQL;
|
||||
use Asterisk::AGI;
|
||||
$AGI = new Asterisk::AGI;
|
||||
|
||||
($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) {$Fhour = "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";
|
||||
$start_time=$now_date;
|
||||
$CIDdate = "$mon$mday$hour$min$sec";
|
||||
$tsSQLdate = "$year$mon$mday$hour$min$sec";
|
||||
$SQLdate = "$year-$mon-$mday $hour:$min:$sec";
|
||||
$SQLdateBEGIN = $SQLdate;
|
||||
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
if ($V) {print STDERR "Perl Environment Dump:\n";}
|
||||
$i=0;
|
||||
while ($#ARGV >= $i)
|
||||
{
|
||||
$args = "$args $ARGV[$i]";
|
||||
if ($V) {print STDERR "$i|$ARGV[$i]|\n";}
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($args =~ /--help/i)
|
||||
{
|
||||
print "allowed run time options:\n [-q] = quiet\n [-t] = test\n [-debug] = verbose debug messages\n\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($args =~ /-V/i)
|
||||
{
|
||||
$V=1;
|
||||
}
|
||||
if ($args =~ /-debug/i)
|
||||
{
|
||||
$DG=1;
|
||||
}
|
||||
if ($args =~ /-dbAVS/i)
|
||||
{
|
||||
$DGA=1;
|
||||
}
|
||||
if ($args =~ /-q/i)
|
||||
{
|
||||
$q=1;
|
||||
$Q=1;
|
||||
}
|
||||
if ($args =~ /-t/i)
|
||||
{
|
||||
$TEST=1;
|
||||
$T=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($V) {print "no command line options set\n";}
|
||||
}
|
||||
|
||||
$|=1;
|
||||
while(<STDIN>)
|
||||
{
|
||||
chomp;
|
||||
last unless length($_);
|
||||
if ($V)
|
||||
{
|
||||
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;}
|
||||
if (/^agi_calleridname\:\s+(.*)$/) {$calleridname = $1;}
|
||||
}
|
||||
|
||||
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 ($V)
|
||||
{
|
||||
|
||||
if ($V) {print STDERR "AGI Environment Dump:\n";}
|
||||
foreach $i (sort keys %AGI) {
|
||||
if ($V) {print STDERR " -- $i = $AGI{$i}\n";}
|
||||
}
|
||||
}
|
||||
|
||||
$VDADcampaign='';
|
||||
$VDADphone='';
|
||||
$VDADphone_code='';
|
||||
|
||||
if ($V) {print STDERR "AGI Environment Dump: |$unique_id|$channel|$extension|$type|$callerid|$calleridname|$priority|\n";}
|
||||
|
||||
|
||||
$callerid =~ s/\"//gi;
|
||||
$CIDlead_id = $callerid;
|
||||
$CIDlead_id = substr($CIDlead_id, 11, 9);
|
||||
$CIDlead_id = ($CIDlead_id + 0);
|
||||
$VD_lead_id = $CIDlead_id;
|
||||
|
||||
if ($V) {print STDERR "\nVD_amd_post : $callerid $channel $priority\n";}
|
||||
if ($M) {print STDERR "+++++ VD amd START : |$unique_id|$channel|$extension|$type|$callerid|$CIDlead_id|$now_date|$AST_ver|$priority|$calleridname|\n";}
|
||||
|
||||
|
||||
if ( ($channel =~ /Local/i) && ($AST_ver !~ /^1\.0\.8|^1\.0\.9/) )
|
||||
{
|
||||
if ($M) {print STDERR "+++++ VDAD START LOCAL CHANNEL: EXITING- $priority\n";}
|
||||
if ($priority > 2) {sleep(1);}
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
########## AMD says it's a machine so modify statuses and hangup call ##########
|
||||
########## something will go here later for leaving a message on AMs ##########
|
||||
if (!$DB_port) {$DB_port='3306';}
|
||||
|
||||
my $dbhA = Net::MySQL->new(hostname=>"$DB_server", database=>"$DB_database", user=>"$DB_user", password=>"$DB_pass", port => "$DB_port") or die "Couldn't connect to database: $DB_server - $DB_database\n";
|
||||
|
||||
$stmtA = "UPDATE vicidial_log set status='AL' where lead_id='$VD_lead_id' order by call_date desc limit 1;";
|
||||
if($M){print STDERR "\n\n|$stmtA|\n";}
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if ($M) {print STDERR "-- VDAD vicidial_log AM update: |$affected_rows|$uniqueid|\n";}
|
||||
|
||||
$stmtA = "UPDATE vicidial_list set status='AL' where lead_id='$VD_lead_id';";
|
||||
if($M){print STDERR "\n\n|$stmtA|\n";}
|
||||
$dbhA->query("$stmtA");
|
||||
my $affected_rows = $dbhA->get_affected_rows_length;
|
||||
if ($M) {print STDERR "-- VDAD vicidial_list AM update: |$affected_rows|$uniqueid|\n";}
|
||||
|
||||
|
||||
|
||||
$dbhA->close;
|
||||
|
||||
|
||||
|
||||
|
||||
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++;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user