All pastes #1483 Raw Edit

ManxPower WIP

public ini v1 · immutable
#1483 ·published 2004-10-15 04:44 UTC
rendered paste body
;; Standard Macros For Stirling and BTEL VOX/Net VoIP Networks; Version: 1.0.0 10/14/2004.  Requires: Asterisk 1.0.1 (later versions may work);; If this example is useful to you, estimate how much time it has saved you,; then send a donation via Paypal to eric@fnords.org;; Copyright (c) 2004 Eric Wieling <eric@fnords.org>; This example is licensed under the GPL.  http://www.gnu.org/licenses/gpl.txt;; Contact eric@fnords.org if you want a non-GPL license. ;[macro-std-exten];; This macro is controlled by the following variables set before the macro; is called.  The variables can be set using SetVar, DBGet, AGI, web based; CGI script, manager interface, government mind control rays, etc.  How; they are set is up to you.;; MOH_CLASS - Music on Hold Class.  Set the music on hold class to this; value.  If empty, don't change the current MOH class.;; DND - Do Not Disturb.  If this variable is not empty, then send call; directly to unavailable voicemail.  Example: SetVar(DND=1) or; SetVar(DND=blah) or SetVar(DND=);; DND_MESSAGE - When DND is set, play this audio file before going to; unavailable voicemail. Example: SetVar(DND_MESSAGE=/tmp/happy-message) or; SetVar(DND_MESSAGE=);; CFU_DEST - Call Forward Unconditional.  If set, unconditionally dial; this destination.  If empty, don't Call Forward Unconditionaly.  Example:; SetVar(CFU_DEST=IAX2/bob@fnords/1234) or SetVar(CFU_DEST=);; CFU_TIMEOUT - When dialing CFU_DEST, how many seconds to wait before; giving up and going to unavailable voicemail.  If empty or 0, never; timeout.  Example: SetVar(CFU_TIMEOUT=20);; CFU_MESSAGE - When dialing CFU_DEST, play this audio file to the caller; first.  If empty, don't play anything.  Example:; SetVar(CFU_MESSAGE=/tmp/happy-message) or SetVar(CFU_MESSAGE=);; CFU_FLAGS - When dialing CFU_DEST, use this variable as the optons on to; the Dial command.  If empty, use the default Dial flags. Example:; SetVar(CFU_FLAGS=mH) or SetVar(CFU_FLAGS=);; CFU_LIMIT - When dialing CFU_DEST, this is the maximum number of; simultaneous calls to allow.  If empty or 0, allow unlimited simultaneous; calls.  Example: SetVar(CFU_LIMIT=1) or SetVar(CFU_LIMIT=);; DIAL_DEST - If DND and CFU_DEST are not set, dial this destination.  If; empty go to unavailable voicemail.  If all the destinations are busy dial; CFBL_DEST.  Example: SetVar(CFU_DEST=IAX2/bob@fnords/1234) or; SetVar(CFU_DEST=SIP/1234&Zap/4);; DIAL_TIMEOUT -  How many seconds to wait before giving up and trying; Call Forward No Answer.  If empty or 0, never timeout. Example:; SetVar(DIAL_TIMEOUT=20);; DIAL_FLAGS - Use this variable as the optons on to the Dial command.  If; empty, use the default Dial flags. Example: SetVar(DIAL_FLAGS=mH) or; SetVar(DIAL_FLAGS=);; ; CFNA_DEST - Call Forward No Answer.  If DIAL_TIMEOUT expires when; dialing DIAL_DEST (call was not answered) then dial this destination. If; empty, don't Call Forward No Answer and go directly to unavailable; voicemail.  If all destinations are busy go directly to unavailable; voicemail.  Example: SetVar(CFNA_DEST=IAX2/bob@fnords/1234) or; SetVar(CFU_DEST=SIP/1234&Zap/4) or SetVar(CFNA_DEST=);; CFNA_TIMEOUT - When dialing CFNA_DEST, how many seconds to wait before; giving up and going to unavailable voicemail.  If empty or 0, never; timeout.  Example: SetVar(CFNA_TIMEOUT=20);; CFNA_MESSAGE - Before dialing CFNA_DEST, play this audio file to the; caller first.  If empty, don't play anything.  Example:; SetVar(CFNA_MESSAGE=/tmp/happy-message) or SetVar(CFNA_MESSAGE=);; CFNA_FLAGS - When dialing CFNA_DEST, use this variable as the optons on; to the Dial command.  If empty, use the default Dial flags. Example:; SetVar(CFNA_FLAGS=mH) or SetVar(CFNA_FLAGS=);; CFNA_LIMIT - When dialing CFNA_DEST, this is the maximum number of; simultaneous calls to allow.  If empty or 0, allow unlimited simultaneous; calls.  Example: SetVar(CFNA_LIMIT=1) or SetVar(CFNA_LIMIT=);; CFBL_DEST - Call Forward Busy Line.  If destination is busy when dialing; DIAL_DEST then dial this destination. If empty, don't Call Forward Busy; Line and go directly to busy voicemail.  Example:; SetVar(CFBL_DEST=IAX2/bob@fnords/1234) or SetVar(CFBL_DEST=SIP/1234&Zap/4); or SetVar(CFBL_DEST=);; CFBL_TIMEOUT - When dialing CFBL_DEST, how many seconds to wait before; giving up and going to busy voicemail.  If empty or 0, never timeout. ; Example: SetVar(CFBL_TIMEOUT=20);; CFBL_MESSAGE - Before dialing CFBL_DEST, play this audio file to the; caller first.  If empty, don't play anything.  Example:; SetVar(CFBL_MESSAGE=/tmp/happy-message) or SetVar(CFBL_MESSAGE=);; CFBL_FLAGS - When dialing CFBL_DEST, use this variable as the optons on; to the Dial command.  If empty, use the default Dial flags. Example:; SetVar(CFBL_FLAGS=mH) or SetVar(CFBL_FLAGS=);; CFBL_LIMIT - When dialing CFBL_DEST, this is the maximum number of; simultaneous calls to allow.  If empty or 0, allow unlimited simultaneous; calls.  Example: SetVar(CFBL_LIMIT=1) or SetVar(CFBL_LIMIT=);; OPERATOR_DEST - Operator Destination.  When a caller presses "0" during; the voicemail greeting, dial this destination.  If all destinations are; busy go back to VoicemailMain.  If empty tell the caller "Invalid Option"; when they press "0" during the voicemail greeting and go back to; VoicemailMain.  Exmaple: SetVar(CFBL_DEST=IAX2/bob@fnords/1234) or; SetVar(CFBL_DEST=SIP/1234&Zap/4) or SetVar(CFBL_DEST=);; OPERATOR_TIMEOUT - When dialing OPERATOR_DEST, how many seconds to wait; before giving up and going to unavailable voicemail.  If empty or 0, never; timeout.  Example: SetVar(OPERATOR_TIMEOUT=20);; OPERATOR_MESSAGE - Before dialing OPERATOR_DEST, play this audio file to; the caller first.  If empty, don't play anything.  Example:; SetVar(OPERATOR_MESSAGE=/tmp/happy-message) or SetVar(OPERATOR_MESSAGE=);; OPERATOR_FLAGS - When dialing OPERATOR_DEST, use this variable as the; optons on to the Dial command.  If empty, use the default Dial flags.; Example: SetVar(OPERATOR_FLAGS=mH) or SetVar(OPERATOR_FLAGS=); ; OPERATOR_LIMIT - When dialing OPERATOR_DEST, this is the maximum number; of simultaneous calls to allow.  If empty or 0, allow unlimited; simultaneous calls.  Example: SetVar(OPERATOR_LIMIT=1) or; SetVar(OPERATOR_LIMIT=);exten => s,1,SetVar(SAVED_EXTEN=${MACRO_EXTEN})exten => s,2,SetVar(SAVED_CONTEXT=${MACRO_CONTEXT})exten => s,3,Macro(callerid-fixup)exten => s,4,GotoIf($[${LEN(${DIAL_DEST})} = 0]?s-NOANSWER,12:5)exten => s,5,GotoIf($[${LEN(${DND})} = 0]?s-dnd,1:6)exten => s,6,GotoIf($[${LEN(${MOH_CLASS})} = 0]?8:7)exten => s,7,SetMusicOnHold(${MOH_CLASS})exten => s,8,GotoIf($[${LEN(${CFU_DEST})} = 0]?10:s-cfu,1)exten => s,9,GotoIf($[${CFNA_TIMEOUT} = 0]?10:11)exten => s,10,SetVar(CFNA_TIMEOUT=)exten => s,11,GotoIf($[${LEN(${DIAL_LIMIT})} = 0]?16:13)exten => s,12,GotoIf($[${DIAL_LIMIT} = 0]?16:14)exten => s,13,SetGroup(${SAVED_EXTEN}-DIAL_LIMIT)exten => s,14,CheckGroup(${CFNA_LIMIT})exten => s,15,Macro(build-dest,${DIAL_DEST})exten => s,16,Dial(${DESTINATION},${DIAL_TIMEOUT},${DIAL_FLAGS})exten => s,17,Goto(s-${DIALSTATUS},1)exten => s,113,Goto(s-BUSY,1)exten => s-NOANSWER,1,GotoIf($[${LEN(${CFNA_DEST})} = 0]?12:2)exten => s-NOANSWER,2,GotoIf($[${CFNA_TIMEOUT} = 0]?3:4)exten => s-NOANSWER,3,SetVar(CFNA_TIMEOUT=)exten => s-NOANSWER,4,GotoIf($[${LEN(${CFNA_LIMIT})} = 0]?8:5)exten => s-NOANSWER,5,GotoIf($[${CFNA_LIMIT} = 0]?8:6)exten => s-NOANSWER,6,SetGroup(${SAVED_EXTEN}-CFNA_LIMIT)exten => s-NOANSWER,7,CheckGroup(${CFNA_LIMIT})exten => s-NOANSWER,8,GotoIf($[${LEN(${CFNA_MESSAGE})} = 0]?10:9)exten => s-NOANSWER,9,Playback(${CFNA_MESSAGE})exten => s-NOANSWER,10,Macro(build-dest,${CFNA_DEST})exten => s-NOANSWER,11,Dial(${DESTINATION},${CFNA_TIMEOUT},${CFNA_FLAGS})exten => s-NOANSWER,12,Voicemail(u${SAVED_EXTEN})exten => s-NOANSWER,13,Hangupexten => s-NOANSWER,108,Goto(12)exten => s-CHANUNAVAIL,1,Goto(s-NOANSWER,1)exten => s-CONGESTION,1,Goto(s-NOANSWER,1)exten => s-CANCEL,1,Goto(s-NOANSWER,1)exten => s-ANSWERED,1,Hangup()exten => a,1,VoicemailMain()exten => o,1,GotoIf($[${LEN(${OPERATOR_DEST})} = 0]?extensions,0,1:2)exten => o,2,GotoIf($[${LEN(${OPERATOR_DEST})} = 0]?11:3)exten => o,3,GotoIf($[${LEN(${OPERATOR_LIMIT})} = 0]?4:5)exten => o,4,SetVar(OPERATOR_LIMIT=1)exten => o,5,SetGroup(${SAVED_EXTEN}-OPERATOR_LIMIT)exten => o,6,CheckGroup(${OPERATOR_LIMIT})exten => o,7,GotoIf($[${LEN(${OPERATOR_MESSAGE})} = 0]?9:8)exten => o,8,Playback(${OPERATOR_MESSAGE})exten => o,9,Macro(build-dest,${OPERATOR_DEST})exten => o,10,Dial(${DESTINATION},${OPERATOR_TIMEOUT},${OPERATOR_FLAGS})exten => o,11,Voicemail(b${SAVED_EXTEN})exten => o,12,Hangupexten => o,107,Goto(o,11)[macro-build-dest]exten => s,1,Cut(DEST1=ARG1,&,1)exten => s,2,Cut(DEST2=ARG1,&,2)exten => s,3,Cut(DEST3=ARG1,&,3)exten => s,4,Cut(DEST4=ARG1,&,4)exten => s,5,GotoIf($[${DEST1:0:3} = Zap]?s,6:s,8)exten => s,6,SetVar(DESTINATION=${DEST1}${CADENCE})exten => s,7,Goto(s,9)exten => s,8,SetVar(DESTINATION=${DEST1})exten => s,9,GotoIf($[${LEN(${DEST2})} = 0]?s,24:s,10)exten => s,10,GotoIf($[${DEST2:0:3} = Zap]?s,11:s,13)exten => s,11,SetVar(DESTINATION=${DESTINATION}&${DEST2}${CADENCE})exten => s,12,Goto(s,14)exten => s,13,SetVar(DESTINATION=${DESTINATION}&${DEST2})exten => s,14,GotoIf($[${LEN(${DEST3})} = 0]?s,24:s,15)exten => s,15,GotoIf($[${DEST3:0:3} = Zap]?s,16:s,18)exten => s,16,SetVar(DESTINATION=${DESTINATION}&${DEST3}${CADENCE})exten => s,17,Goto(s,14)exten => s,18,SetVar(DESTINATION=${DESTINATION}&${DEST3})exten => s,19,GotoIf($[${LEN(${DEST4})} = 0]?s,24:s,20)exten => s,20,GotoIf($[${DEST4:0:3} = Zap]?s,21:s,23)exten => s,21,SetVar(DESTINATION=${DESTINATION}&${DEST4}${CADENCE})exten => s,22,Goto(s,24)exten => s,23,SetVar(DESTINATION=${DESTINATION}&${DEST4})exten => s,24,NoOp[macro-set-ring]exten => s,1,NoOp(CALLERIDNUM=${CALLERIDNUM})exten => s,2,GotoIf($[${LEN(${CALLERIDNUM})} = 4]?s,5:s,3)exten => s,3,SetVar(CADENCE=r2)exten => s,4,SetVar(ALERT_INFO=<Bellcore-dr2>)exten => s,5,NoOp[macro-callerid-fixup];; This macro assumes the following:;   Extensions without a DID number have their CallerID number set to their 4 digit extension;   Extensions with a DID number have their CallerID number set to their 10 digit DID;   The last 4 digits of a DID number is the same as the extension number;exten => s,1,NoOp(Original Caller*ID: ${CALLERIDNUM})exten => s,2,GotoIf($["${MACRO_CONTEXT}" = "incoming"]?exit,1:s,3)exten => s,3,GotoIf($["${SAVED_CONTEXT}" = "incoming"]?exit,1:s,4)exten => s,4,GotoIf($[${LEN(${SAVED_EXTEN})} = 0]?s,5:s,6)exten => s,5,SetVar(SAVED_EXTEN=${MACRO_EXTEN})exten => s,6,GotoIf($[${LEN(${CALLERIDNUM})} = 0]?skip,1:s,7)exten => s,7,GotoIf($[${LEN(${CALLERIDNUM})} = 4]?ext2,1:s,8)exten => s,8,GotoIf($[${LEN(${CALLERIDNUM})} != 4]?did2,1:exit,1)exten => ext2,1,GotoIf($[${LEN(${SAVED_EXTEN})} != 4]?ext2pstn,1:ext2,2)exten => ext2,2,GotoIf($[${LEN(${SAVED_EXTEN})} = 4]?exit,1:exit,1)exten => did2,1,GotoIf($[${LEN(${SAVED_EXTEN})} = 4]??did2ext,1:did2,2)exten => did2,2,GotoIf($[${LEN(${SAVED_EXTEN})} != 4]?exit,1:exit,1)exten => ext2pstn,1,NoOp(Caller*ID ${CALLERIDNUM} changed to ${ARG1})exten => ext2pstn,2,SetCIDNum(${ARG1})exten => did2ext,1,NoOp(Caller*ID ${CALLERIDNUM} changed to ${CALLERIDNUM:6})exten => did2ext,2,SetCIDNum(${CALLERIDNUM:6})exten => exit,1,NoOp(Caller*ID ${CALLERIDNUM} not changed)[macro-dial-result];; Handle Disconnect Cause Codes;exten => s,1,NoOp(HANGUPCAUSE is ${HANGUPCAUSE} and DIALSTATUS is ${DIALSTATUS})exten => s,2,AbsoluteTimeout(120)exten => s,3,GotoIf($[${HANGUPCAUSE} = 0]?s,5)exten => s,4,Goto(cause-${HANGUPCAUSE},1)exten => s,5,GotoIf($[${DIALSTATUS} = NOANSWER]?cause-16,1)exten => s,6,GotoIf($[${DIALSTATUS} = BUSY]?cause-17,1)exten => s,7,GotoIf($[${DIALSTATUS} = CHANUNAVAIL]?cause-16,1)exten => s,8,GotoIf($[${DIALSTATUS} = ANSWER]?cause-16,1)exten => s,9,Goto(cause-0,1)                                                                                                                                                                                                                                                            exten => cause-0,1,NoOp(AST_CAUSE_NOTDEFINED)exten => cause-0,2,GotoIf($["${SAVED_EXTEN}" != ""]?cause-0,4)exten => cause-0,3,SetVar(SAVED_EXTEN=${MACRO_EXTEN})exten => cause-0,4,GotoIf($["${SAVED_ARG1}" != ""]?cause-0,6)exten => cause-0,5,SetVar(SAVED_ARG1=${ARG1})exten => cause-0,6,GotoIf($["${ARG1}" = ""]?cause-0,11)exten => cause-0,7,System(/bin/echo "AST_CAUSE_NOTDEFINED received when dialing ${SAVED_EXTEN} trying again using ${SAVED_ARG1}." | /bin/mail -s "${SITE} PBX ERROR" pbxadmin-pager@stirlingprop.com)exten => cause-0,8,SetVar(ARG1=)exten => cause-0,9,Dial(${SAVED_ARG1})exten => cause-0,10,Macro(dial-result)exten => cause-0,11,System(/bin/echo "AST_CAUSE_NOTDEFINED received when dialing ${SAVED_ARG1} giving up." | /bin/mail -s "${SITE} PBX ERROR" pbxadmin-pager@stirlingprop.com)exten => cause-0,12,Zapateller(answer)exten => cause-0,13,Playback(an-error-has-occured)exten => cause-0,14,Playback(pls-try-call-later)exten => cause-0,15,Wait(3)exten => cause-0,16,Zapateller(answer)exten => cause-0,17,Playback(an-error-has-occured)exten => cause-0,18,Playback(pls-try-call-later)exten => cause-0,19,Wait(3)exten => cause-0,20,Congestionexten => cause-1,1,NoOp(AST_CAUSE_UNALLOCATED)exten => cause-1,2,Macro(number-disconnected,${MACRO_EXTEN})                                                                                                                                                                                                                                                            exten => cause-16,1,NoOp(AST_CAUSE_NORMAL_CLEARING)exten => cause-16,2,Hangup                                                                                                                                                                                                                                                            exten => cause-17,1,NoOp(AST_CAUSE_USER_BUSY)exten => cause-17,2,Busy                                                                                                                                                                                                                                                            [macro-say-digits];; ARG1=number to say;; Should handle 1-6 digits, 7 digits, 8 digits, 10 digits, 11 digits, 12 digits;;exten => s,1,GotoIf($[${LEN(${ARG1})} != 10]?s,3)exten => s,2,SayDigits(${ARG1:0:3})exten => s,3,GotoIf($[${LEN(${ARG1})} != 10]?s,6)exten => s,4,Wait(.25)exten => s,5,SayDigits(${ARG1:3:3})exten => s,6,GotoIf($[${LEN(${ARG1})} != 10]?s,10)exten => s,7,Wait(.25)exten => s,8,SayDigits(${ARG1:6})exten => s,9,Goto(s,12)exten => s,10,Wait(.25)exten => s,11,SayDigits(${ARG1})exten => s,12,NoOp[macro-number-changed];; ARG1=new number;exten => s,1,Zapateller(answer)exten => s,2,Playback(the-number-u-dialed)exten => s,3,Wait(.25)exten => s,4,Macro(say-digits,${MACRO_EXTEN})exten => s,5,Wait(.25)exten => s,6,Playback(has-been-changed-to)exten => s,7,Wait(.25)exten => s,8,Macro(say-digits,${ARG1})exten => s,9,Wait(.25)exten => s,10,Playback(pls-wait-connect-call)exten => s,11,Goto(extensions,${ARG1},1)[macro-number-disconnected];; ARG1=number dialed;exten => s,1,Zapateller(answer)exten => s,2,Wait(.25)exten => s,3,Playback(the-number-u-dialed)exten => s,4,Wait(.25)exten => s,5,Macro(say-digits,${ARG1})exten => s,6,Wait(.25)exten => s,7,Playback(has-been-disconnected)exten => s,8,Playback(or)exten => s,9,Playback(no-longer-in-service)exten => s,10,Wait(.25)exten => s,11,Playback(no-info-about-number)exten => s,12,Wait(3)exten => s,13,Zapateller(answer)exten => s,14,Wait(.25)exten => s,15,Playback(the-number-u-dialed)exten => s,16,Wait(.25)exten => s,17,Macro(say-digits,${ARG1})exten => s,18,Wait(.25)exten => s,19,Playback(has-been-disconnected)exten => s,20,Playback(or)exten => s,21,Playback(no-longer-in-service)exten => s,22,Wait(.25)exten => s,23,Playback(no-info-about-number)exten => s,24,Wait(3)exten => s,25,Congestion