Код: Выделить всё
[macro-limit]
exten => s,1,Set(Group()=${ARG1})
exten => s,n,Set(Calls=${GROUP_COUNT(${ARG1}@in)})
exten => s,n,GotoIf($[${Calls}>1]?111)
exten => s,n,Dial(SIP/${ARG1},20,tT)
exten => s,111,Verbose(1, ***Количество вызовов ${Calls} больше лимита)
exten => s,n,Set(DIALSTATUS=CHANUNAVAIL)
[office]
exten => _5.,1,Verbose(1, ***** Вызов абонента ${EXTEN} *****)
exten => _5.,n,Macro(limit,${EXTEN})
Код: Выделить всё
-- Executing [5001@office:1] Verbose("SIP/5000-00000000", "1, ***** Вызов абонента 5001 *****") in new stack
***** Вызов абонента 5001 *****
-- Executing [5001@office:2] Macro("SIP/5000-00000000", "limit,5001") in new stack
-- Executing [s@macro-limit:1] Set("SIP/5000-00000000", "Group()=5001") in new stack
-- Executing [s@macro-limit:2] Set("SIP/5000-00000000", "Calls=0") in new stack
-- Executing [s@macro-limit:3] GotoIf("SIP/5000-00000000", "0?111") in new stack
-- Executing [s@macro-limit:4] Dial("SIP/5000-00000000", "SIP/5001,20,tT") in new stack