может быть NO ANSWER да же, если кто-то ответил на звонок.
;; Это надо вставить перед вызовом очереди
same => n,Set(CHANNEL(hangup_handler_push)=hdlr-queue-miss-call,s,1(${CALLERID(num)})
[hdlr-queue-miss-call]
exten => s,1,Noop(---==== Handler queue miss call ===---)
same => n,Set(CLIENT_NUMBER=${ARG1})
same => n,GotoIf($[${ABANDONED}]?:end_call)
same => n,AGI(tg-noanswer.php, ${CLIENT_NUMBER}, ${STRFTIME(${EPOCH},,%Y.%m.%d--H:%M:%S)})
same => n(end_call),Hangup()
[local]
exten => _0[1-9]XXX,1,Noop
same => n,Set(CALLEID(num)=08${CALLRID(num)})
same => n,Dial(SIP/SecretLine/${EXTEN},15,Tt)
same => n,HangUp()
exten => _0[1-9]XXXX,1,Noop
same => n,Set(CALLEID(num)=08${CALLRID(num)})
same => n,Dial(SIP/SecretLine/${EXTEN},15,Tt) same => n,HangUp()
[internal]
same => _XXX.,Dial(SIP/${EXTEN},60,WwtTrU(sub-mixmonitor,${CALLERID(num)},${EXTEN},${UNIQUEID}))
same => n,HangUp()
[sub-mixmonitor]
exten => s,1,Noop(------------MixMonitor---------------)
; same => n,DumpChan()
; same => n,NoCDR()
same => n,Noop(DIALEDPEERNUMBER ${DIALEDPEERNUMBER} )
same => n,Set(FILE_UNIQUEID=${ARG3})
same => n,Noop(UNIQUEID = ${FILE_UNIQUEID})
same => n,GotoIf($[${DB_EXISTS(RECORD/${ARG1})}]?go-record)
same => n,GotoIf($[${DB_EXISTS(RECORD/${ARG2})}]?go-record)
same => n,Goto(end_sub)
same => n(go-record),Set(WAV=/var/spool/asterisk/monitor/${FILE_UNIQUEID})
same => n,Set(filedate=${STRFTIME(${EPOCH},,%Y%m%d_%H-%M-%S)})
same => n,Set(foldername=${STRFTIME(${EPOCH},,%Y/%m)})
same => n,Set(filename=${filedate}_${ARG1:-10}_${ARG2:-10}_${FILE_UNIQUEID})
same => n,Set(MP3=/var/spool/asterisk/monitor/mp3/${foldername}/${filename})
same => n,System(mkdir -p /var/spool/asterisk/monitor/mp3/${foldername})
same => n,Set(monopt=nice -n 19 /usr/bin/lame -b 32 --silent "${WAV}.wav" "${MP3}.mp3" && rm -rf "${WAV}.wav" && chmod o+r "${MP3}.mp3")
same => n,Noop(${CDR(record)})
same => n,Noop(CHANNEL ${CHANNEL(exten)})
same => n,Set(CDR(realdst)=${ARG2});
same => n,Set(CDR(record)=${FILE_UNIQUEID})
same => n,Set(CDR(recordingfile)=${filename}.mp3)
same => n,MixMonitor(${WAV}.wav,b,${monopt})
same => n(end_sub),return
exten => _0[1-3]XXX,1,Noop(---- call to AST A1 ----)
same => n,Set(CALLEID(num)=02${CALLRID(num)}) ;; Подменяем номер звонящего, что бы работал обратный звонок
same => n,Dial(SIP/trunkA1/${EXTEN:3},15,Tt)
same => n,HangUp() ;; Обрываем звонок по окончании или если произошла ошибка что бы не звонить в пожарную службу
Необходимо их различать.
1500 - допустим внутренний номер оператора
*220 - номер по которому операторы меняют свое имя каждое утро, можно добавить проверку что бы они не забывали это делать.
[app-register-operator]
exten => _*220,1,Answer
same => n,Noop(-------app-register-operator----)
same => n,Set(MYPIN=NOPIN)
same => n,Read(${MYPIN},enterPin,,,4,15)
same => n,Goto(go-${MYPIN})
same => n(go-2232,Noop(------register-ping-${MYPIN}------)
same => n,Set(DB(AOPERATOR/1500)="Operator1")
same => n,HangUP()
same => n(go-3321),Noop(------register-ping-${MYPIN}------)
same => n,Set(DB(AOPERATOR/1500)="Operator2")
same => n,HangUP()
same => n(go-NOPIN),Noop(------register-ping-${MYPIN}------)
same => n,Set(DB(AOPERATOR/1500)="NotSet")
same => n,HangUP()
[dial]
exten => _X.,1,Noop(----Internal-Call----)
same => n,GotoIf($[${DB(AOPERATOR/${CALLERID(num)})}= NotSet]?:go-notset)
same => n,Set(CDR(userfield)=${DB(AOPERATOR/${CALLERID(num)})}) ;; добавляем в CDR имя в специальное поле в DB cdr, или любое другое поле
same => n,Dial(SIP/${EXTEN})
same => n,HangUp()
same => n(go-notset),PlayBack(phoneNotRegister_PleaseRegisterBeforeCall)
same => n,HangUp()
Добавить задание в крон которое будет скидывать значение после работы
asterisk -rx "database put AOPERATOR 1500 NotSet"
exten = s-BUSY,1,Playback(${CallisBusy})
[busy]
mode=files
directory=moh_busy
exten => _X.,1,NoOp(-------MAIN-DIALPLAN---------)
same => n,GotoIf($["${DEVICE_STATE(PJSIP/${EXTEN})}" = "UNKNOWN"]?unknown)
same => n,GotoIf($["${DEVICE_STATE(PJSIP/${EXTEN})}" = "INVALID"]?invalid)
same => n,GotoIf($["${DEVICE_STATE(PJSIP/${EXTEN})}" = "UNAVAILABLE"]?unavailable)
same => n,ExecIf($["${DEVICE_STATE(PJSIP/${EXTEN})}" = "INUSE"]?SET(MOH_FILE=busy))
same => n,ExecIf($["${DEVICE_STATE(PJSIP/${EXTEN})}" = "BUSY"]?SET(MOH_FILE=busy))
same => n,Dial(PJSIP/${EXTEN},60,m(${MOH_FILE}))
;; Unavailable
same => n(unavailable),Noop(---Unavailable---)
same => n,PlayBack(unavailable)
same => n,HangUp()
;; Unknown
same => n(unknown),Noop(----Unknown----)
same => n,PlayBack(unknown)
same => n,HangUp()
;; Invalid
same => n(invalid),Noop(----Invalid----)
same => n,PlayBack(invalid)
same => n,HangUp()
exten => _X.,1,NoOp(-------MAIN-DIALPLAN---------)
same => n,GotoIf($["${DEVICE_STATE(PJSIP/${EXTEN})}" = "UNKNOWN"]?unknown)
same => n,GotoIf($["${DEVICE_STATE(PJSIP/${EXTEN})}" = "INVALID"]?invalid)
same => n,GotoIf($["${DEVICE_STATE(PJSIP/${EXTEN})}" = "UNAVAILABLE"]?unavailable)
same => n,GotoIf($["${DEVICE_STATE(PJSIP/${EXTEN})}" = "INUSE"]?busy)
same => n,GotoIf($["${DEVICE_STATE(PJSIP/${EXTEN})}" = "BUSY"]?busy)
same => n,Dial(PJSIP/${EXTEN},60)
same => n,HangUp()
same => n(busy),Dial(PJSIP/${EXTEN},60,m(busy))
same => n,HangUp()
;; Unavailable
same => n(unavailable),Noop(---Unavailable---)
same => n,PlayBack(unavailable)
same => n,HangUp()
;; Unknown
same => n(unknown),Noop(----Unknown----)
same => n,PlayBack(unknown)
same => n,HangUp()
;; Invalid
same => n(invalid),Noop(----Invalid----)
same => n,PlayBack(invalid)
same => n,HangUp()
Но имя месяца почему-то пишется на английском (%B)
[sip]
exten => _X.,1,NoOp(Checking CallerID against blacklist)
same => n,Set(CHANNEL(hangup_handler_push)=hdlr-blacklist,s,1())
same => n,GotoIf($[${DB_EXISTS(blacklist/${CALLERID(num)})}]?go-endcall)
same => n,Set(records=/etc/asterisk/rec/${STRFTIME(${EPOCH},,%H_%M_%d-%m-%Y)}-${CALLERID(number)}-${EXTEN}.wav)
same => n,MixMonitor(${records})
same => n,Dial(SIP/1002,15)
same => n(go-endcall),HangUp()
[hdlr-blacklist]
exten => s,1,Verbose(0, -----hdlr-blacklist-----)
same => n,Verbose(0, CDR BILLSEC is ${CDR(billsec)})
same => n,Verbose(0, CDR disposition is ${CDR(disposition)})
same => n,Set(CALLSTATUS="${CDR(disposition)}")
;same => n,ExecIf($[${CDR(billsec)}>5]?Set(CALLSTATUS="ANSWERED"):Set(CALLSTATUS="NO ANSWERED") ;; можно к времени звонка привязаться
same => n,GotoIf($[${CALLSTATUS}="ANSWERED"]?:go-endcall)
same => n,Verbose(0, CALLSTATUS is ${CALLSTATUS})
same => n,Set(DB(blacklist/${CALLERID(num)})=1)
same => n(go-endcall),Return()
указать внешний дублирующий номер - "внешний номер"
Есть ещё идея создать outbound route для определенного внутреннего номера что бы станция звонила на этот же номер и на дополнительный- это возможно?
[context-playback]
exten => s,1,Noop(----PlayBack---)
same => n,Answer()
same => n,PlayBack(file)
same => n,HangUp()
Channel: Local/7777777777@from-internal
MaxRetries: 0
WaitTime: 60
Context: context-playback
Extension: s
Priority: 1
[local_calls-p1]
exten => _[1-9],1,NoOp(Call on local subscriber)
same => n,Dial(PJSIP/10${EXTEN},30)
same => n,Playback(kv-number&vm-isunavail)
same => n,Hangup()
exten => _[1-5][0,1-7],1,NoOp(Call on local subscriber)
same => n,Dial(PJSIP/1${EXTEN},30)
same => n,Playback(kv-number&vm-isunavail)
same => n,Hangup()