星号 - 在上下文中减少extensions.conf中的扩展重复

时间:2014-01-06 07:25:13

标签: sip voip asterisk telephony asteriskami

我有一个非常基本的extensions.conf,其中包含以下context

[LocalPhones]

exten => 1001,1,noop(Dialing ${PEX_ONE})
        same => n,Macro(DialStartMonitor,${PEX_ONE})
        same => n,Dial(SIP/${PEX_ONE},30,mTt)
        same => n,Playback(vm-nobodyavail)      ; Play "no one's available"
        same => n,Hangup()

exten => 1002,1,noop(Dialing ${PEX_TWO})
        same => n,Macro(DialStartMonitor,${PEX_TWO})
        same => n,Dial(SIP/${PEX_TWO},30,mTt)
        same => n,Playback(vm-nobodyavail)      ; Play "no one's available"
        same => n,Hangup()

exten => 1003,1,noop(Dialing ${PEX_THREE})
        same => n,Macro(DialStartMonitor,${PEX_THREE})
        same => n,Dial(SIP/${PEX_THREE},30,mTt)
        same => n,Playback(vm-nobodyavail)      ; Play "no one's available"
        same => n,Hangup()

exten => 1004,1,Dial(Dialing ${PEX_FOUR})
        same => n,Macro(DialStartMonitor,${PEX_FOUR})
        same => n,Dial(SIP/${PEX_FOUR},10,m)
        same => n,Playback(vm-nobodyavail)      ; Play "no one's available"
        same => n,Hangup()

exten => 1005,1,Dial(Dialing ${PEX_FIVE})
        same => n,Macro(DialStartMonitor,${PEX_FIVE})
        same => n,Dial(SIP/${PEX_FIVE},10,m)
        same => n,Playback(vm-nobodyavail)      ; Play "no one's available"
        same => n,Hangup()

有没有办法可以将所有这些组合成一个块(而不是像现在这样的5个块),这样扩展可以互相拨号(扩展名从1001到1010)?

2 个答案:

答案 0 :(得分:4)

星号的正确值放置拨号方案就像这样

exten => 1000,1,Set(trunk=${PEX_ONE})
exten => 1002,1,Set(trunk=${PEX_TWO})
exten => 1003,1,Set(trunk=${PEX_THREE})
exten => 1004,1,Set(trunk=${PEX_PHONE})
exten => 1005,1,Set(trunk=${PEX_FIVE})
; this will be executed after any of above
; note,it start from 2 prio(1 is from set above)
exten => _100[1-5],2,Noop(Dialing ${trunk})
           same => n,Macro(DialStartMonitor,${trunk})
           same => n,Dial(SIP/${trunk},10,m)
           same => n,Playback(vm-nobodyavail)      ; Play "no one's available"
           same => n,Hangup()

请注意,您的拨号方案仍然不好,因为即使用户忙或通信没问题,它也可以播放vm-nobodyavail,但是被称为用户。

对于正确的拨号方案,你需要分析DIALSTATUS变量,检查extensions.conf.sample这样的拨号方案或者阅读freepbx.org软件的拨号方案。

答案 1 :(得分:0)

我认为它会像贝娄一样:

exten => _100[12345],1,Set(DIALTO=${PEX_ONE})
        same => n,GotoIf($["${EXTEN:-1}" = "1"]?process)
        same => n,Set(DIALTO=${PEX_TWO})
        same => n,GotoIf($["${EXTEN:-1}" = "2"]?process)
        same => n,Set(DIALTO=${PEX_THREE})
        same => n,GotoIf($["${EXTEN:-1}" = "3"]?process)
        same => n,Set(DIALTO=${PEX_FOUR})
        same => n,GotoIf($["${EXTEN:-1}" = "4"]?process)
        same => n,Set(DIALTO=${PEX_FIVE})
        same => n(process),Macro(DialStartMonitor,${DIALTO})
        same => n,Dial(SIP/${DIALTO},30,mTt)
        same => n,Playback(vm-nobodyavail)      ; Play "no one's available"
        same => n,Hangup()