| 1 |
context dialextens |
| 2 |
{ |
| 3 |
/* |
| 4 |
101 thru 123, 149 thru 152 |
| 5 |
*/ |
| 6 |
_10X => Dial(Zap/${EXTEN:2},30,Ttw); |
| 7 |
_1ZX => Dial(Zap/${EXTEN:1},30,Ttw); |
| 8 |
} |
| 9 |
/* |
| 10 |
Due to extenal wiring: |
| 11 |
|
| 12 |
dialing 125 will ring 101 |
| 13 |
dialing 126 will ring 102 |
| 14 |
and so on until |
| 15 |
dialing 147 will ring 123 |
| 16 |
|
| 17 |
We can dial out on zap 69 thru 72; and 25-47 |
| 18 |
|
| 19 |
*/ |
| 20 |
|
| 21 |
context dialthrus |
| 22 |
{ |
| 23 |
/* 369-372; 325-347 */ |
| 24 |
_3XX => Dial(Zap/${EXTEN:1},30,Ttw); |
| 25 |
} |
| 26 |
|
| 27 |
context t1incoming |
| 28 |
{ |
| 29 |
includes |
| 30 |
{ |
| 31 |
dialextens; |
| 32 |
parkedcalls; |
| 33 |
} |
| 34 |
s => { |
| 35 |
Answer(); |
| 36 |
Background(welcome-to-test-machine); |
| 37 |
} |
| 38 |
|
| 39 |
} |
| 40 |
|
| 41 |
context t1extension |
| 42 |
{ |
| 43 |
includes |
| 44 |
{ |
| 45 |
dialextens; |
| 46 |
dialthrus; |
| 47 |
} |
| 48 |
|
| 49 |
} |
| 50 |
|
| 51 |
context incoming |
| 52 |
{ |
| 53 |
includes |
| 54 |
{ |
| 55 |
dialextens; |
| 56 |
parkedcalls; |
| 57 |
} |
| 58 |
s => { |
| 59 |
Answer(); |
| 60 |
Background(welcome-to-test-machine); |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
context incoming |
| 65 |
{ |
| 66 |
s => { |
| 67 |
Answer(); |
| 68 |
} |
| 69 |
} |
| 70 |
|
| 71 |
macro std-priv-exten( dev, ext , timeout, opts, torcont, dontcont ) |
| 72 |
{ |
| 73 |
// &increment_chosecount(); |
| 74 |
dial_again: |
| 75 |
Dial(${dev},${timeout},${opts}); |
| 76 |
switch(${DIALSTATUS}) |
| 77 |
{ |
| 78 |
case TORTURE: |
| 79 |
goto ${torcont}|s|begin; |
| 80 |
break; |
| 81 |
|
| 82 |
case DONTCALL: |
| 83 |
goto ${dontcont}|s|begin; |
| 84 |
break; |
| 85 |
|
| 86 |
case BUSY: |
| 87 |
label_busy: |
| 88 |
Read(reply|work-exten-busy|1||2|15); |
| 89 |
if ("${reply}"=="") |
| 90 |
goto label_busy; // infinite loop if Read has probs!! |
| 91 |
switch(${reply}) |
| 92 |
{ |
| 93 |
case 1: |
| 94 |
Set(time1=${EPOCH}); |
| 95 |
|
| 96 |
label_redial: |
| 97 |
|
| 98 |
WaitMusicOnHold(5); |
| 99 |
Dial(${dev},${timeout},${opts}); |
| 100 |
|
| 101 |
switch(${DIALSTATUS}) |
| 102 |
{ |
| 103 |
case BUSY: |
| 104 |
if(${EPOCH}-${time1} >= 20) |
| 105 |
goto label_busy; |
| 106 |
goto label_redial; |
| 107 |
|
| 108 |
default: |
| 109 |
return;// goto work_line|s|loopback; |
| 110 |
} |
| 111 |
break; |
| 112 |
case 2: |
| 113 |
Voicemail(${ext}|b); |
| 114 |
break; |
| 115 |
case 3: |
| 116 |
return; // goto work_line|s|loopback; |
| 117 |
default: |
| 118 |
Background(invalid); |
| 119 |
goto label_busy; |
| 120 |
} |
| 121 |
break; |
| 122 |
|
| 123 |
case ANSWER: |
| 124 |
break; |
| 125 |
|
| 126 |
case NOANSWER: |
| 127 |
noanswer_label: |
| 128 |
Read(reply|work-exten-noanswer|1|skip|2|15); |
| 129 |
switch(${reply}) |
| 130 |
{ |
| 131 |
case 1: |
| 132 |
switch(${ext}) |
| 133 |
{ |
| 134 |
case 10: |
| 135 |
Background(no-cell); |
| 136 |
break; |
| 137 |
case 11: |
| 138 |
// &ciddial(2729495,3072729495,30,tw,${GRAMS_TELCO},${WORK_TELCO}); |
| 139 |
break; |
| 140 |
case 12: |
| 141 |
// &ciddial(2725560,3072725560,30,tw,${GRAMS_TELCO},${WORK_TELCO}); |
| 142 |
break; |
| 143 |
case 13: |
| 144 |
// &ciddial(2720197,3072720197,30,tw,${GRAMS_TELCO},${WORK_TELCO}); |
| 145 |
break; |
| 146 |
case 14: |
| 147 |
// &ciddial(2501174,3072501174,30,tw,${GRAMS_TELCO},${WORK_TELCO}); |
| 148 |
break; |
| 149 |
case 15: |
| 150 |
Background(no-cell); |
| 151 |
break; |
| 152 |
case 16: |
| 153 |
Background(no-cell); |
| 154 |
break; |
| 155 |
default: |
| 156 |
Background(invalid); |
| 157 |
break; |
| 158 |
} |
| 159 |
goto noanswer_label; |
| 160 |
break; |
| 161 |
case 2: |
| 162 |
Voicemail(${ext}|u); |
| 163 |
break; |
| 164 |
case 3: |
| 165 |
return; // goto work_line|s|loopback; |
| 166 |
default: |
| 167 |
Background(invalid); |
| 168 |
goto noanswer_label; |
| 169 |
} |
| 170 |
Voicemail(${ext}|u); |
| 171 |
break; |
| 172 |
default: |
| 173 |
Voicemail(${ext}|u); |
| 174 |
} |
| 175 |
} |
| 176 |
/* Putting these 3 funcs in extensions.conf! |
| 177 |
macro funcC(a,b) |
| 178 |
{ |
| 179 |
Set(Key=); |
| 180 |
menu: |
| 181 |
Read(Key,main-menu,1,n,1,5); |
| 182 |
if("${Key}" = "2") |
| 183 |
goto y,lab1; |
| 184 |
catch y |
| 185 |
{ lab1: |
| 186 |
&funcB(${a},${b}); |
| 187 |
} |
| 188 |
} |
| 189 |
|
| 190 |
macro funcB(a,b) |
| 191 |
{ |
| 192 |
Set(Key=); |
| 193 |
menu: |
| 194 |
Read(Key,tt-monkeys,1,n,1,5); |
| 195 |
if("${Key}" = "2") |
| 196 |
goto z,lab2; |
| 197 |
catch z |
| 198 |
{ lab2: |
| 199 |
&funcC(${a},${b}); |
| 200 |
} |
| 201 |
} |
| 202 |
|
| 203 |
macro funcA() |
| 204 |
{ |
| 205 |
&funcB(1,2); |
| 206 |
} |
| 207 |
*/ |
| 208 |
|
| 209 |
context extension |
| 210 |
{ |
| 211 |
includes |
| 212 |
{ |
| 213 |
dialextens; |
| 214 |
dialthrus; |
| 215 |
parkedcalls; |
| 216 |
} |
| 217 |
5 => { |
| 218 |
Record(recording:wav); |
| 219 |
Background(recording); |
| 220 |
} |
| 221 |
|
| 222 |
81 => { |
| 223 |
iterations=1000000; |
| 224 |
Set(time1=${EPOCH}); |
| 225 |
for(i=1; ${i}<${iterations}; i=${i}+1) |
| 226 |
{ |
| 227 |
NoOp(Hello); |
| 228 |
} |
| 229 |
Set(time2=${EPOCH}); |
| 230 |
Verbose(The time diff is $[${time2} - ${time1} ] seconds); |
| 231 |
Verbose(Which means that the priorities/sec = $[4* ${iterations} / (${time2} - ${time1}) ]); |
| 232 |
SayNumber($[4 * ${iterations} / (${time2} - ${time1}) ]); |
| 233 |
} |
| 234 |
82 => { |
| 235 |
&ndeep(100000); |
| 236 |
Verbose(Finished 100000 levels deep call!); |
| 237 |
} |
| 238 |
83 => { |
| 239 |
switch (${EXTEN}) |
| 240 |
{ |
| 241 |
pattern 8X: |
| 242 |
Verbose(do something to prepare it); |
| 243 |
pattern 9X: |
| 244 |
Verbose(handle both 1xx and 2xx calls); |
| 245 |
pattern [4-7]X: |
| 246 |
Verbose(and this too!); |
| 247 |
} |
| 248 |
Set(junky=${RAND(0|99999)}); |
| 249 |
Verbose(Here is a random number: ${junky}.); |
| 250 |
} |
| 251 |
84 => { |
| 252 |
agi(agi://192.168.134.252/|hello|goodbye|whatever|whoknows,hell2,hello3); |
| 253 |
} |
| 254 |
85 => { |
| 255 |
&std-priv-exten( Zap/50, 150 , 25, mtw, torcont, dontcont ); |
| 256 |
} |
| 257 |
86 => { |
| 258 |
Verbose(The version is: ${VERSION()} ); |
| 259 |
Verbose(The versionnum is: ${VERSION(ASTERISK_VERSION_NUM)} ); |
| 260 |
Verbose(The user is: ${VERSION(BUILD_USER)} ); |
| 261 |
Verbose(The hostname is: ${VERSION(BUILD_HOSTNAME)} ); |
| 262 |
Verbose(The machine is: ${VERSION(BUILD_MACHINE)} ); |
| 263 |
Verbose(The OS is: ${VERSION(BUILD_OS)} ); |
| 264 |
Verbose(The date is: ${VERSION(BUILD_DATE)} ); |
| 265 |
Verbose(The kernel is: ${VERSION(BUILD_KERNEL)} ); |
| 266 |
Set(vinf=${VERSION()}); |
| 267 |
Set(vrand=${RAND()}); |
| 268 |
if( ${ISNULL(${vinf})} ) |
| 269 |
{ |
| 270 |
if( ${ISNULL(${vrand})} ) |
| 271 |
Verbose(Version 1.2 or earlier); |
| 272 |
else |
| 273 |
Verbose(Version 1.4!!!); |
| 274 |
} |
| 275 |
else |
| 276 |
Verbose(${vinf} indicates version pre-1.6 or higher); |
| 277 |
} |
| 278 |
871 => { |
| 279 |
NoOp( 1 1 1 1 1 1 1); |
| 280 |
NoOp( 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6); |
| 281 |
NoOp(012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678890123456789012345678901234567890); |
| 282 |
NoOp(${EXTEN:1:2} ${EXTEN} ${EXTEN:1} 1 1 1 1 1 1 1); |
| 283 |
&dialoutpstn(${TDIRECTCALL-PST}/0${EXTEN},${E${CALLERID(num)}-OPT},${TDIRECTCALL-CID},${TDIRECTCALL-MAX},RotaPadrao) ; |
| 284 |
|
| 285 |
} |
| 286 |
872 => { |
| 287 |
Set(ChannelOnly=${CUT(CHANNEL||1)}); |
| 288 |
Verbose(ChannelOnly=${ChannelOnly}; neat huh?); |
| 289 |
Set(ChannelOnly=${CUT(CHANNEL,,1)}); |
| 290 |
Verbose(ChannelOnly=${ChannelOnly}; neat huh?); |
| 291 |
} |
| 292 |
873 => { |
| 293 |
NOOP(this is a forkcdr test); |
| 294 |
Set(CALLERID(num)=1234567890); |
| 295 |
Set(CALLERID(name)=before fork); |
| 296 |
Forkcdr(v); |
| 297 |
Set(CALLERID(num)=0987654321); |
| 298 |
Set(CALLERID(name)=after fork); |
| 299 |
Answer(); |
| 300 |
Echo(); |
| 301 |
Hangup(); |
| 302 |
} |
| 303 |
874 => { |
| 304 |
SayDigits(307-754-5675); |
| 305 |
SayPhoneNumber(307-754-5675); |
| 306 |
SayDigits(--); |
| 307 |
SayPhoneNumber(123-456-7890); |
| 308 |
SayDigits(++); |
| 309 |
SayPhoneNumber(307-754-4454); |
| 310 |
} |
| 311 |
875 => { |
| 312 |
&funcA(); |
| 313 |
&funcD(); |
| 314 |
} |
| 315 |
876 => { |
| 316 |
NoOp(Query resultid ${connid} SELECT var1\, var2 FROM did); |
| 317 |
NoOp($["Query resultid ${connid} SELECT var1\, var2 FROM did"]); |
| 318 |
NoOp($["Query resultid ${connid} SELECT var1, var2 FROM did"]); |
| 319 |
goto test5,s,1; |
| 320 |
} |
| 321 |
88 => { |
| 322 |
SET(LIMIT_PLAYAUDIO_CALLER=yes); |
| 323 |
SET(LIMIT_PLAYAUDIO_CALLEE=no); |
| 324 |
SET(LIMIT_TIMEOUT_FILE=timeup); |
| 325 |
SET(LIMIT_CONNECT_FILE=limit60); |
| 326 |
SET(LIMIT_WARNING_FILE=almostup); |
| 327 |
Dial(Zap/51,20,L(60000:30000:8000)); |
| 328 |
} |
| 329 |
89 => { |
| 330 |
goto callbackmenu|100|1; |
| 331 |
} |
| 332 |
} |
| 333 |
|
| 334 |
context income1 |
| 335 |
{ |
| 336 |
s => { |
| 337 |
Answer(); |
| 338 |
Dial(Zap/50,20,m); |
| 339 |
} |
| 340 |
150 => Dial(Zap/50,20,m); |
| 341 |
} |
| 342 |
|
| 343 |
context callbackmenu |
| 344 |
{ |
| 345 |
_X. => { |
| 346 |
Answer(); |
| 347 |
Wait(1); |
| 348 |
Set(TIMEOUT(digit)=5); |
| 349 |
Set(TIMEOUT(response)=30); |
| 350 |
DISA(no-password,callbackdialout); |
| 351 |
} |
| 352 |
} |
| 353 |
|
| 354 |
context callbackdialout |
| 355 |
{ |
| 356 |
_X. => { |
| 357 |
Dial(Zap/51,20,w); |
| 358 |
} |
| 359 |
|
| 360 |
} |
| 361 |
|
| 362 |
|
| 363 |
macro dialoutpstn(something1, something2, something3, something4, something5) |
| 364 |
{ |
| 365 |
Verbose(${something1}--- ${something2}--- ${something3}--- ${something4}--- ${something5}); |
| 366 |
} |
| 367 |
|
| 368 |
macro ndeep(level) |
| 369 |
{ |
| 370 |
if( ${level} == 0) |
| 371 |
{ |
| 372 |
Verbose(2|Got to Level 0); |
| 373 |
return; |
| 374 |
} |
| 375 |
&ndeep($[${level}-1]); |
| 376 |
return; |
| 377 |
} |