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