星号 - 宏 GotoIf 或运算符
Asterisk - macro GotoIf or operator
Asterisk 16.13.0
想根据来电号码在(primo、secondo、terzo 和 bo)之间切换操作。
[macro-gigi]
exten => s,1,NoOp(macro-gigi: ${CALLERID(num)} - ${CALLERID(all)} - ${CHANNEL})
exten => s,n,GotoIf($["${CALLERID(num)}"="207"]?primo)
exten => s,n,GotoIf($["${CALLERID(num)}"="205"|"206"]?secondo:terzo)
exten => s,n(bo),NoOp(caller not managed: ${CALLERID(num)} - ${EXTEN} - ${CALLERID(all)} - ${CHANNEL})
exten => s,n,MacroExit
exten => s,n(primo),NoOp(primo: ${CALLERID(num)} - ${CALLERID(all)} - ${CHANNEL})
exten => s,n,MacroExit
exten => s,n(secondo),NoOp(secondo: ${CALLERID(num)} - ${CALLERID(all)} - ${CHANNEL})
exten => s,n,MacroExit
exten => s,n(terzo),NoOp(terzo: ${CALLERID(num)} - ${CALLERID(all)} - ${CHANNEL})
exten => s,n,GotoIf($["${CALLERID(num)}"="203"|"204"]?:bo)
exten => s,n,NoOp(terzo: ${CALLERID(num)} - ${CALLERID(all)} - ${CHANNEL})
exten => s,n,MacroExit
如果来电者是 207,它 运行 primo 就可以了。
如果来电者是 203 或 204,它 运行 是错误的。
如果来电者是 206 或 205,它 运行 第二,这很好。
如果来电者是其他人运行其次,这是错误的。
我不明白使用 OR 运算符 ="205"|"206"
或 gotoif 序列是否有误。
-- Executing [s@macro-gigi:1] NoOp("SIP/206-00000042", "macro-gigi: 206 - SIP/206-00000042") in new stack
-- Executing [s@macro-gigi:2] GotoIf("SIP/206-00000042", "0?primo") in new stack
-- Executing [s@macro-gigi:3] GotoIf("SIP/206-00000042", ""206"?secondo:terzo") in new stack
-- Goto (macro-gigi,s,8)
-- Executing [s@macro-gigi:8] NoOp("SIP/206-00000042", "secondo: 206 - SIP/206-00000042") in new stack
-- Executing [s@macro-gigi:9] MacroExit("SIP/206-00000042", "") in new stack
-- Executing [s@macro-gigi:1] NoOp("SIP/203-00000044", "macro-gigi: 203 - SIP/203-00000044") in new stack
-- Executing [s@macro-gigi:2] GotoIf("SIP/203-00000044", "0?primo") in new stack
-- Executing [s@macro-gigi:3] GotoIf("SIP/203-00000044", ""206"?secondo:terzo") in new stack
-- Goto (macro-gigi,s,8)
-- Executing [s@macro-gigi:8] NoOp("SIP/203-00000044", "secondo: 203 - SIP/203-00000044") in new stack
-- Executing [s@macro-gigi:9] MacroExit("SIP/203-00000044", "") in new stack
-- Executing [s@macro-gigi:1] NoOp("SIP/204-00000045", "macro-gigi: 204 - SIP/204-00000045") in new stack
-- Executing [s@macro-gigi:2] GotoIf("SIP/204-00000045", "0?primo") in new stack
-- Executing [s@macro-gigi:3] GotoIf("SIP/204-00000045", ""206"?secondo:terzo") in new stack
-- Goto (macro-gigi,s,8)
-- Executing [s@macro-gigi:8] NoOp("SIP/204-00000045", "secondo: 204 - SIP/204-00000045") in new stack
-- Executing [s@macro-gigi:9] MacroExit("SIP/204-00000045", "") in new stack
-- Executing [s@macro-gigi:1] NoOp("SIP/205-00000043", "macro-gigi: 205 - SIP/205-00000043") in new stack
-- Executing [s@macro-gigi:2] GotoIf("SIP/205-00000043", "0?primo") in new stack
-- Executing [s@macro-gigi:3] GotoIf("SIP/205-00000043", "1?secondo:terzo") in new stack
-- Goto (macro-gigi,s,8)
-- Executing [s@macro-gigi:8] NoOp("SIP/205-00000043", "secondo: 205 - SIP/205-00000043") in new stack
-- Executing [s@macro-gigi:9] MacroExit("SIP/205-00000043", "") in new stack
-- Executing [s@macro-gigi:1] NoOp("PJSIP/102-00000050", "macro-gigi: 102 - PJSIP/102-00000050") in new stack
-- Executing [s@macro-gigi:2] GotoIf("PJSIP/102-00000050", "0?primo") in new stack
-- Executing [s@macro-gigi:3] GotoIf("PJSIP/102-00000050", ""206"?secondo:terzo") in new stack
-- Goto (macro-gigi,s,8)
-- Executing [s@macro-gigi:8] NoOp("PJSIP/102-00000050", "secondo: 102 - PJSIP/102-00000050") in new stack
-- Executing [s@macro-gigi:9] MacroExit("PJSIP/102-00000050", "") in new stack
编辑:
通过此更改,一切正常,但不是 DRY:
exten => s,1,NoOp(macro-gigi: ${CALLERID(num)} - ${CHANNEL})
exten => s,n,GotoIf($["${CALLERID(num)}"="205"]?secondo)
exten => s,n,GotoIf($["${CALLERID(num)}"="206"]?secondo)
exten => s,n,GotoIf($["${CALLERID(num)}"="207"]?primo)
exten => s,n,GotoIf($["${CALLERID(num)}"="203"]?terzo)
exten => s,n,GotoIf($["${CALLERID(num)}"="204"]]?terzo:bo)
205|206 结果为 1
exten => s,n,GotoIf($[ $[ "${CALLERID(num)}"="205"] | $["${CALLERID(num)}"="206"] ]?secondo)
https://www.voip-info.org/asterisk-expressions/
但这不是星号方式。星号的方式是这样的:
exten => s,1,NoOp(macro-gigi: ${CALLERID(num)} - ${CHANNEL})
exten => s/_20[56],n,Goto(secondo);actually really asterisk way is do what needed on this patern
exten => s/207,1,NoOp(primo: ${CALLERID(num)} - ${CALLERID(all)} - ${CHANNEL})
same => n,Nopo(other dialplan for 207)
same => n,MacroExit
exten => s/_20[34],1,Goto(terzo)
exten => s/_2XX,1,Goto(bo);other
https://wiki.asterisk.org/wiki/display/AST/Pattern+Matching
如果您需要类似宏的行为,请使用 gosub/return。宏已删除。
Asterisk 16.13.0
想根据来电号码在(primo、secondo、terzo 和 bo)之间切换操作。
[macro-gigi]
exten => s,1,NoOp(macro-gigi: ${CALLERID(num)} - ${CALLERID(all)} - ${CHANNEL})
exten => s,n,GotoIf($["${CALLERID(num)}"="207"]?primo)
exten => s,n,GotoIf($["${CALLERID(num)}"="205"|"206"]?secondo:terzo)
exten => s,n(bo),NoOp(caller not managed: ${CALLERID(num)} - ${EXTEN} - ${CALLERID(all)} - ${CHANNEL})
exten => s,n,MacroExit
exten => s,n(primo),NoOp(primo: ${CALLERID(num)} - ${CALLERID(all)} - ${CHANNEL})
exten => s,n,MacroExit
exten => s,n(secondo),NoOp(secondo: ${CALLERID(num)} - ${CALLERID(all)} - ${CHANNEL})
exten => s,n,MacroExit
exten => s,n(terzo),NoOp(terzo: ${CALLERID(num)} - ${CALLERID(all)} - ${CHANNEL})
exten => s,n,GotoIf($["${CALLERID(num)}"="203"|"204"]?:bo)
exten => s,n,NoOp(terzo: ${CALLERID(num)} - ${CALLERID(all)} - ${CHANNEL})
exten => s,n,MacroExit
如果来电者是 207,它 运行 primo 就可以了。
如果来电者是 203 或 204,它 运行 是错误的。
如果来电者是 206 或 205,它 运行 第二,这很好。
如果来电者是其他人运行其次,这是错误的。
我不明白使用 OR 运算符 ="205"|"206"
或 gotoif 序列是否有误。
-- Executing [s@macro-gigi:1] NoOp("SIP/206-00000042", "macro-gigi: 206 - SIP/206-00000042") in new stack
-- Executing [s@macro-gigi:2] GotoIf("SIP/206-00000042", "0?primo") in new stack
-- Executing [s@macro-gigi:3] GotoIf("SIP/206-00000042", ""206"?secondo:terzo") in new stack
-- Goto (macro-gigi,s,8)
-- Executing [s@macro-gigi:8] NoOp("SIP/206-00000042", "secondo: 206 - SIP/206-00000042") in new stack
-- Executing [s@macro-gigi:9] MacroExit("SIP/206-00000042", "") in new stack
-- Executing [s@macro-gigi:1] NoOp("SIP/203-00000044", "macro-gigi: 203 - SIP/203-00000044") in new stack
-- Executing [s@macro-gigi:2] GotoIf("SIP/203-00000044", "0?primo") in new stack
-- Executing [s@macro-gigi:3] GotoIf("SIP/203-00000044", ""206"?secondo:terzo") in new stack
-- Goto (macro-gigi,s,8)
-- Executing [s@macro-gigi:8] NoOp("SIP/203-00000044", "secondo: 203 - SIP/203-00000044") in new stack
-- Executing [s@macro-gigi:9] MacroExit("SIP/203-00000044", "") in new stack
-- Executing [s@macro-gigi:1] NoOp("SIP/204-00000045", "macro-gigi: 204 - SIP/204-00000045") in new stack
-- Executing [s@macro-gigi:2] GotoIf("SIP/204-00000045", "0?primo") in new stack
-- Executing [s@macro-gigi:3] GotoIf("SIP/204-00000045", ""206"?secondo:terzo") in new stack
-- Goto (macro-gigi,s,8)
-- Executing [s@macro-gigi:8] NoOp("SIP/204-00000045", "secondo: 204 - SIP/204-00000045") in new stack
-- Executing [s@macro-gigi:9] MacroExit("SIP/204-00000045", "") in new stack
-- Executing [s@macro-gigi:1] NoOp("SIP/205-00000043", "macro-gigi: 205 - SIP/205-00000043") in new stack
-- Executing [s@macro-gigi:2] GotoIf("SIP/205-00000043", "0?primo") in new stack
-- Executing [s@macro-gigi:3] GotoIf("SIP/205-00000043", "1?secondo:terzo") in new stack
-- Goto (macro-gigi,s,8)
-- Executing [s@macro-gigi:8] NoOp("SIP/205-00000043", "secondo: 205 - SIP/205-00000043") in new stack
-- Executing [s@macro-gigi:9] MacroExit("SIP/205-00000043", "") in new stack
-- Executing [s@macro-gigi:1] NoOp("PJSIP/102-00000050", "macro-gigi: 102 - PJSIP/102-00000050") in new stack
-- Executing [s@macro-gigi:2] GotoIf("PJSIP/102-00000050", "0?primo") in new stack
-- Executing [s@macro-gigi:3] GotoIf("PJSIP/102-00000050", ""206"?secondo:terzo") in new stack
-- Goto (macro-gigi,s,8)
-- Executing [s@macro-gigi:8] NoOp("PJSIP/102-00000050", "secondo: 102 - PJSIP/102-00000050") in new stack
-- Executing [s@macro-gigi:9] MacroExit("PJSIP/102-00000050", "") in new stack
编辑:
通过此更改,一切正常,但不是 DRY:
exten => s,1,NoOp(macro-gigi: ${CALLERID(num)} - ${CHANNEL})
exten => s,n,GotoIf($["${CALLERID(num)}"="205"]?secondo)
exten => s,n,GotoIf($["${CALLERID(num)}"="206"]?secondo)
exten => s,n,GotoIf($["${CALLERID(num)}"="207"]?primo)
exten => s,n,GotoIf($["${CALLERID(num)}"="203"]?terzo)
exten => s,n,GotoIf($["${CALLERID(num)}"="204"]]?terzo:bo)
205|206 结果为 1
exten => s,n,GotoIf($[ $[ "${CALLERID(num)}"="205"] | $["${CALLERID(num)}"="206"] ]?secondo)
https://www.voip-info.org/asterisk-expressions/
但这不是星号方式。星号的方式是这样的:
exten => s,1,NoOp(macro-gigi: ${CALLERID(num)} - ${CHANNEL})
exten => s/_20[56],n,Goto(secondo);actually really asterisk way is do what needed on this patern
exten => s/207,1,NoOp(primo: ${CALLERID(num)} - ${CALLERID(all)} - ${CHANNEL})
same => n,Nopo(other dialplan for 207)
same => n,MacroExit
exten => s/_20[34],1,Goto(terzo)
exten => s/_2XX,1,Goto(bo);other
https://wiki.asterisk.org/wiki/display/AST/Pattern+Matching
如果您需要类似宏的行为,请使用 gosub/return。宏已删除。