[ext-queues]
include => ext-queues-custom
exten => 500,1,Macro(user-callerid,)
exten => 500,n,Answer
exten => 500,n,Macro(blkvm-set,reset)
exten => 500,n,ExecIf($["${REGEX("(M[(]auto-blkvm[)])" ${DIAL_OPTIONS})}" != "1"]?Set(_DIAL_OPTIONS=${DIAL_OPTIONS}M(auto-blkvm)))
exten => 500,n,Set(__NODEST=${EXTEN})
exten => 500,n,Set(QCIDPP=${IF($[${LEN(${VQ_CIDPP})}>0]?${VQ_CIDPP}: )})
exten => 500,n,Set(VQ_CIDPP=)
exten => 500,n,ExecIf($["${QCIDPP}"!=""]?Macro(prepend-cid,${QCIDPP}))
exten => 500,n,Set(QAINFO=${IF($[${LEN(${VQ_AINFO})}>0]?${VQ_AINFO}: )})
exten => 500,n,Set(VQ_AINFO=)
exten => 500,n,ExecIf($["${QAINFO}"!=""]?Set(__ALERT_INFO=${QAINFO}))
exten => 500,n,Set(QJOINMSG=${IF($[${LEN(${VQ_JOINMSG})}>0]?${IF($["${VQ_JOINMSG}"!="0"]?${VQ_JOINMSG}: )}: )})
exten => 500,n,Set(VQ_JOINMSG=)
exten => 500,n,Set(QRINGOPTS=r)
exten => 500,n,Set(QRETRY=${IF($[${LEN(${VQ_RETRY})}>0]?${VQ_RETRY}:n)})
exten => 500,n,Set(VQ_RETRY=)
exten => 500,n(qoptions),Set(QOPTIONS=${IF($[${LEN(${VQ_OPTIONS})}>0]?${VQ_OPTIONS}:t)}${QCANCELMISSED}${QRINGOPTS}${QRETRY})
exten => 500,n,Set(VQ_OPTIONS=)
exten => 500,n(qgosub),Set(QGOSUB=${IF($[${LEN(${VQ_GOSUB})}>0]?${VQ_GOSUB}:${QGOSUB})})
exten => 500,n,Set(VQ_GOSUB=)
exten => 500,n(qagi),Set(QAGI=${IF($[${LEN(${VQ_AGI})}>0]?${VQ_AGI}:${QAGI})})
exten => 500,n,Set(VQ_AGI=)
exten => 500,n(qrule),Set(QRULE=${IF($[${LEN(${VQ_RULE})}>0]?${IF($["${VQ_RULE}"!="0"]?${VQ_RULE}: )}:${QRULE})})
exten => 500,n,Set(VQ_RULE=)
exten => 500,n(qposition),Set(QPOSITION=${IF($[${LEN(${VQ_POSITION})}>0]?${VQ_POSITION}:${QPOSITION})})
exten => 500,n,Set(VQ_POSITION=)
exten => 500,n,Gosub(sub-record-check,s,1(q,500,force))
exten => 500,n,Set(__CFIGNORE=TRUE)
exten => 500,n,Set(__FORWARD_CONTEXT=block-cf)
exten => 500,n,ExecIf($["${QJOINMSG}"!=""]?Playback(${QJOINMSG}, ))
exten => 500,n,QueueLog(500,${UNIQUEID},NONE,DID,${FROM_DID})
exten => 500,n,Set(QAANNOUNCE=${IF($[${LEN(${VQ_AANNOUNCE})}>0]?${IF($["${VQ_AANNOUNCE}"!="0"]?${VQ_AANNOUNCE}: )}: )})
exten => 500,n,Set(VQ_AANNOUNCE=)
exten => 500,n,Set(QMOH=${IF($["${VQ_MOH}"!=""]?${VQ_MOH}: )})
exten => 500,n,Set(VQ_MOH=)
exten => 500,n,ExecIf($["${QMOH}"!=""]?Set(__MOHCLASS=${QMOH}))
exten => 500,n,ExecIf($["${MOHCLASS}"!=""]?Set(CHANNEL(musicclass)=${MOHCLASS}))
exten => 500,n,Set(QMAXWAIT=${IF($[${LEN(${VQ_MAXWAIT})}>0]?${VQ_MAXWAIT}:30)})
exten => 500,n,Set(VQ_MAXWAIT=)
exten => 500,n,Set(QUEUENUM=500)
exten => 500,n,Set(QUEUEJOINTIME=${EPOCH})
exten => 500,n(qcall),Queue(500,${QOPTIONS},,${QAANNOUNCE},${QMAXWAIT},${QAGI},,${QGOSUB},${QRULE},${QPOSITION})
exten => 500,n,Macro(blkvm-clr,)
exten => 500,n,Gosub(sub-record-cancel,s,1())
exten => 500,n,Set(__NODEST=)
exten => 500,n,Set(_QUEUE_PRIO=0)
exten => 500,n,Set(__CFIGNORE=)
exten => 500,n,Set(__FORWARD_CONTEXT=from-internal)
exten => 500,n,Set(QRINGOPTS=)
exten => 500,n,Set(QDEST=${VQ_DEST})
exten => 500,n,Set(VQ_DEST=)
exten => 500,n(gotodest),GotoIf($["${QDEST}"=""]?app-blackhole,zapateller,1:${CUT(QDEST,^,1)},${CUT(QDEST,^,2)},${CUT(QDEST,^,3)})

exten => 500*,1,Macro(agent-add,500,)

exten => 500**,1,Macro(agent-del,500)

exten => *45500,1,Set(QUEUENO=500)
exten => *45500,n,Goto(app-queue-toggle,s,start)
exten => _*45XXXX*XXX,1,Set(QUEUENO=${EXTEN:8:3})
exten => _*45XXXX*XXX,n,Set(QUEUEUSER=${EXTEN:3:4})
exten => _*45XXXX*XXX,n,Goto(app-queue-toggle,s,start)
exten => _*45XXXX*XXX,hint,Custom:QUEUE${EXTEN:3}
