Files
mattf 295941e007 Created stable release branch of 2.0.5
git-svn-id: svn://192.168.202.10@1074 3d104415-ff17-0410-8863-d5cf3c621b8a
2009-03-15 13:59:55 +00:00

124 lines
2.4 KiB
Perl

#!/usr/bin/perl
#
# debug_speak.agi version 2.0.5
#
# runs during any extension and speaks the extension sent to it while
# printing the extension as well as lots of info about the call to STDERR
#
# You need to put lines similar to those below in your extensions.conf file:
#
# ;inbound errors with speaking of extension:
#exten => _XXXX,1,AGI(debug_speak.agi,${EXTEN})
#exten => _XXXX,3,Hangup
#
# Copyright (C) 2008 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
$V = 1; # set to 1 for verbose mode
$CLIOUT = 1; # set to 1 for printing 1 line to STDERR
$SPEAK = 1; # set to 1 for saying invalid digits
($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";
### begin parsing run-time options ###
if (length($ARGV[0])>1)
{
if ($CLIOUT) {print STDERR "Perl Environment Dump:\n";}
$i=0;
while ($#ARGV >= $i)
{
$args = "$args $ARGV[$i]";
if ($CLIOUT) {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";}
}
use Asterisk::AGI;
$AGI = new Asterisk::AGI;
$|=1;
while(<STDIN>) {
chomp;
last unless length($_);
if ($V)
{
if (/^agi_(\w+)\:\s+(.*)$/)
{
$AGI{$1} = $2;
}
}
if (/^agi_uniqueid\:\s+(.*)$/) {$unique_id = $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 ($V)
{
if ($V) {print STDERR "AGI Environment Dump:\n";}
foreach $i (sort keys %AGI) {
if ($V) {print STDERR " -- $i = $AGI{$i}\n";}
}
}
if ($CLIOUT) {print STDERR "****** DEBUG: |$unique_id|$channel|$extension|$type|$callerid|$calleridname|\n";}
if ($SPEAK)
{
$AGI->stream_file('beep');
sleep(1);
$AGI->say_digits("$extension");
}
exit;