Вот макрос:
| Код: |
| [macro-dial-auto-route] ;--- first part of this macros normalize phone number to format len of 11 symbol, ex. 84712777777 exten => s,1,Set(tel1=${ARG1}) exten => s,n,Noop("Incoming before normalize number: "${tel1}) ;--- check for 6x cities num exten => s,n,GotoIf($[LEN(${tel1})]="6")]?gorod6x:nogorod6x) exten => s,n(gorod6x),Set(tel1=4712${tel1}) ;--- extract 10x part of number exten => s,n(nogorod6x),Set(tel1=8${tel1:-10}) exten => s,n,GotoIf($[LEN(${tel1})]="11")]?valid) exten => s,n,noop("WRONG number "${tel1}" length:"$[LEN(${tel1})]"MUST BE 11") exten => s,n,hangup() ;--- end for normalize number of phone ;--- begin routing part, next code accepted incoming only 11X format, example 89038885555 or 84712777777 exten => s,n,Noop("Number after normalize: "${tel1}) ;---- cheking KURK or other number exten => s,n(valid),GotoIf($["${tel1:1:4}" = "4712"]?gorod) exten => s,n,GotoIf($["${tel1:0:2}" = "89"]?mobile) exten => s,n,noop("We hawen't ROUTE to this phone number"${tel1}") exten => s,n,Hangup() ;--- SEND Kursk sities numbers to PROSTOR exten => s,n(gorod),Set(CALLERID(num)=4712777888) exten => s,n,Dial(DAHDI/g1/${tel1}} exten => s,n,Hangup() ;--- mobiles to MEGAFON GSM exten => s,n(mobile),Macro(gsm-dialout,${tel1}) exten => s,n,Hangup() |
Вот Notice:
| Код: |
| == Using SIP RTP CoS mark 5 -- Executing [310123@office:1] Answer("SIP/200-00001d84", "") in new stack -- Executing [310123@office:2] Macro("SIP/200-00001d84", "dial-auto-route,777777") in new stack -- Executing [s@macro-dial-auto-route:1] Set("SIP/200-00001d84", "tel1=777777") in new stack -- Executing [s@macro-dial-auto-route:2] NoOp("SIP/200-00001d84", ""Incoming before normalize number: "777777") in new stack [Sep 11 03:43:42] NOTICE[29647]: ast_expr2.y:760 compose_func_args: argbuf allocated 7 bytes; [Sep 11 03:43:42] NOTICE[29647]: ast_expr2.y:779 compose_func_args: argbuf uses 6 bytes; -- Executing [s@macro-dial-auto-route:3] GotoIf("SIP/200-00001d84", "6="6")]?gorod6x:nogorod6x") in new stack -- Goto (macro-dial-auto-route,s,4) -- Executing [s@macro-dial-auto-route:4] Set("SIP/200-00001d84", "tel1=4712777777") in new stack -- Executing [s@macro-dial-auto-route:5] Set("SIP/200-00001d84", "tel1=84712777777") in new stack [Sep 11 03:43:42] NOTICE[29647]: ast_expr2.y:760 compose_func_args: argbuf allocated 12 bytes; [Sep 11 03:43:42] NOTICE[29647]: ast_expr2.y:779 compose_func_args: argbuf uses 11 bytes; -- Executing [s@macro-dial-auto-route:6] GotoIf("SIP/200-00001d84", "11="11")]?valid") in new stack -- Goto (macro-dial-auto-route,s,10) -- Executing [s@macro-dial-auto-route:10] GotoIf("SIP/200-00001d84", "1?gorod") in new stack -- Goto (macro-dial-auto-route,s,14) -- Executing [s@macro-dial-auto-route:14] Set("SIP/200-00001d84", "CALLERID(num)=4712777888") in new stack -- Executing [s@macro-dial-auto-route:15] Dial("SIP/200-00001d84", "DAHDI/g1/84712777777}") in new stack -- Requested transfer capability: 0x00 - SPEECH -- Called DAHDI/g1/84712777777} |
| Код: |
| GotoIf($[LEN(${tel1})]="6")]?gorod6x:nogorod6x) |
У вас сравнение ЧИСЛОВОЙ и текстовой переменной. Сделайте так
GotoIf($[LEN(${tel1})]=6)]?gorod6x:nogorod6x)
или поставьте кавычки до и после вычисления длинны номера
_________________
P4 3.0 + 1Gb CentOS 5.7 Aster 1.8.15.1
Не люблю gui-сборки: натуральный продукт вкуснее.
И еще: я ПРОФИ так как НЕ ЛЕНЮСЬ читать литературу.
| Код: |
| -- Executing [310123@office:2] Macro("SIP/200-00001f80", "dial-auto-route,777777") in new stack -- Executing [s@macro-dial-auto-route:1] Set("SIP/200-00001f80", "tel1=777777") in new stack -- Executing [s@macro-dial-auto-route:2] NoOp("SIP/200-00001f80", ""Incoming before normalize number: "777777") in new stack [Sep 11 12:57:01] NOTICE[32106]: ast_expr2.y:760 compose_func_args: argbuf allocated 7 bytes; [Sep 11 12:57:01] NOTICE[32106]: ast_expr2.y:779 compose_func_args: argbuf uses 6 bytes; -- Executing [s@macro-dial-auto-route:3] GotoIf("SIP/200-00001f80", "6=6)]?gorod6x:nogorod6x") in new stack -- Goto (macro-dial-auto-route,s,4) -- Executing [s@macro-dial-auto-route:4] Set("SIP/200-00001f80", "tel1=4712777777") in new stack -- Executing [s@macro-dial-auto-route:5] Set("SIP/200-00001f80", "tel1=84712777777") in new stack [Sep 11 12:57:01] NOTICE[32106]: ast_expr2.y:760 compose_func_args: argbuf allocated 12 bytes; [Sep 11 12:57:01] NOTICE[32106]: ast_expr2.y:779 compose_func_args: argbuf uses 11 bytes; -- Executing [s@macro-dial-auto-route:6] GotoIf("SIP/200-00001f80", "11=11)]?valid") in new stack -- Goto (macro-dial-auto-route,s,9) -- Executing [s@macro-dial-auto-route:9] NoOp("SIP/200-00001f80", ""Number after normalize: "84712777777") in new stack -- Executing [s@macro-dial-auto-route:10] GotoIf("SIP/200-00001f80", "1?gorod") in new stack -- Goto (macro-dial-auto-route,s,14) -- Executing [s@macro-dial-auto-route:14] Set("SIP/200-00001f80", "CALLERID(num)=4712777888") in new stack -- Executing [s@macro-dial-auto-route:15] Dial("SIP/200-00001f80", "DAHDI/g1/84712777777}") in new stack -- Requested transfer capability: 0x00 - SPEECH -- Called DAHDI/g1/84712310123} |
| Код: |
| exten => s,n,GotoIf($[${LEN(${tel1})} = 11)]?valid) |
Сравнение строк:
| Код: |
| exten => s,n,GotoIf($["${LEN(${tel1})}": "11")]?valid) |