You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
4.6 KiB

5 months ago
  1. <!doctype html>
  2. <title>CodeMirror: Asterisk dialplan mode</title>
  3. <meta charset="utf-8"/>
  4. <link rel=stylesheet href="../../doc/docs.css">
  5. <link rel="stylesheet" href="../../lib/codemirror.css">
  6. <script src="../../lib/codemirror.js"></script>
  7. <script src="../../addon/edit/matchbrackets.js"></script>
  8. <script src="asterisk.js"></script>
  9. <style>
  10. .CodeMirror {border: 1px solid #999;}
  11. .cm-s-default span.cm-arrow { color: red; }
  12. </style>
  13. <div id=nav>
  14. <a href="https://codemirror.net/5"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a>
  15. <ul>
  16. <li><a href="../../index.html">Home</a>
  17. <li><a href="../../doc/manual.html">Manual</a>
  18. <li><a href="https://github.com/codemirror/codemirror5">Code</a>
  19. </ul>
  20. <ul>
  21. <li><a href="../index.html">Language modes</a>
  22. <li><a class=active href="#">Asterisk dialplan</a>
  23. </ul>
  24. </div>
  25. <article>
  26. <h2>Asterisk dialplan mode</h2>
  27. <form><textarea id="code" name="code">
  28. ; extensions.conf - the Asterisk dial plan
  29. ;
  30. [general]
  31. ;
  32. ; If static is set to no, or omitted, then the pbx_config will rewrite
  33. ; this file when extensions are modified. Remember that all comments
  34. ; made in the file will be lost when that happens.
  35. static=yes
  36. #include "/etc/asterisk/additional_general.conf
  37. [iaxprovider]
  38. switch => IAX2/user:[key]@myserver/mycontext
  39. [dynamic]
  40. #exec /usr/bin/dynamic-peers.pl
  41. [trunkint]
  42. ;
  43. ; International long distance through trunk
  44. ;
  45. exten => _9011.,1,Macro(dundi-e164,${EXTEN:4})
  46. exten => _9011.,n,Dial(${GLOBAL(TRUNK)}/${FILTER(0-9,${EXTEN:${GLOBAL(TRUNKMSD)}})})
  47. [local]
  48. ;
  49. ; Master context for local, toll-free, and iaxtel calls only
  50. ;
  51. ignorepat => 9
  52. include => default
  53. [demo]
  54. include => stdexten
  55. ;
  56. ; We start with what to do when a call first comes in.
  57. ;
  58. exten => s,1,Wait(1) ; Wait a second, just for fun
  59. same => n,Answer ; Answer the line
  60. same => n,Set(TIMEOUT(digit)=5) ; Set Digit Timeout to 5 seconds
  61. same => n,Set(TIMEOUT(response)=10) ; Set Response Timeout to 10 seconds
  62. same => n(restart),BackGround(demo-congrats) ; Play a congratulatory message
  63. same => n(instruct),BackGround(demo-instruct) ; Play some instructions
  64. same => n,WaitExten ; Wait for an extension to be dialed.
  65. exten => 2,1,BackGround(demo-moreinfo) ; Give some more information.
  66. exten => 2,n,Goto(s,instruct)
  67. exten => 3,1,Set(LANGUAGE()=fr) ; Set language to french
  68. exten => 3,n,Goto(s,restart) ; Start with the congratulations
  69. exten => 1000,1,Goto(default,s,1)
  70. ;
  71. ; We also create an example user, 1234, who is on the console and has
  72. ; voicemail, etc.
  73. ;
  74. exten => 1234,1,Playback(transfer,skip) ; "Please hold while..."
  75. ; (but skip if channel is not up)
  76. exten => 1234,n,Gosub(${EXTEN},stdexten(${GLOBAL(CONSOLE)}))
  77. exten => 1234,n,Goto(default,s,1) ; exited Voicemail
  78. exten => 1235,1,Voicemail(1234,u) ; Right to voicemail
  79. exten => 1236,1,Dial(Console/dsp) ; Ring forever
  80. exten => 1236,n,Voicemail(1234,b) ; Unless busy
  81. ;
  82. ; # for when they're done with the demo
  83. ;
  84. exten => #,1,Playback(demo-thanks) ; "Thanks for trying the demo"
  85. exten => #,n,Hangup ; Hang them up.
  86. ;
  87. ; A timeout and "invalid extension rule"
  88. ;
  89. exten => t,1,Goto(#,1) ; If they take too long, give up
  90. exten => i,1,Playback(invalid) ; "That's not valid, try again"
  91. ;
  92. ; Create an extension, 500, for dialing the
  93. ; Asterisk demo.
  94. ;
  95. exten => 500,1,Playback(demo-abouttotry); Let them know what's going on
  96. exten => 500,n,Dial(IAX2/guest@pbx.digium.com/s@default) ; Call the Asterisk demo
  97. exten => 500,n,Playback(demo-nogo) ; Couldn't connect to the demo site
  98. exten => 500,n,Goto(s,6) ; Return to the start over message.
  99. ;
  100. ; Create an extension, 600, for evaluating echo latency.
  101. ;
  102. exten => 600,1,Playback(demo-echotest) ; Let them know what's going on
  103. exten => 600,n,Echo ; Do the echo test
  104. exten => 600,n,Playback(demo-echodone) ; Let them know it's over
  105. exten => 600,n,Goto(s,6) ; Start over
  106. ;
  107. ; You can use the Macro Page to intercom a individual user
  108. exten => 76245,1,Macro(page,SIP/Grandstream1)
  109. ; or if your peernames are the same as extensions
  110. exten => _7XXX,1,Macro(page,SIP/${EXTEN})
  111. ;
  112. ;
  113. ; System Wide Page at extension 7999
  114. ;
  115. exten => 7999,1,Set(TIMEOUT(absolute)=60)
  116. exten => 7999,2,Page(Local/Grandstream1@page&Local/Xlite1@page&Local/1234@page/n,d)
  117. ; Give voicemail at extension 8500
  118. ;
  119. exten => 8500,1,VoicemailMain
  120. exten => 8500,n,Goto(s,6)
  121. </textarea></form>
  122. <script>
  123. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  124. mode: "text/x-asterisk",
  125. matchBrackets: true,
  126. lineNumbers: true
  127. });
  128. </script>
  129. <p><strong>MIME types defined:</strong> <code>text/x-asterisk</code>.</p>
  130. </article>