-
Notifications
You must be signed in to change notification settings - Fork 9
/
debug_speak.agi
executable file
·123 lines (108 loc) · 2.43 KB
/
debug_speak.agi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/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 <[email protected]> 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) {$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";
### 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;