extensions.ael 9.0 KB

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