1

我想在通话挂断时执行一个脚本,所以我在 extensions_custom.conf 中创建了一个自定义上下文,如下所示:

[coscon]
exten => **5,1,NoOp()
same => n,Answer()
exten => h,1,System(/usr/local/src/myscript.php)

问题是在此上下文中的 hangup h 扩展之后根本没有执行。有什么建议吗?

更新

让我详细说明一下。在 extensions_custom.conf 文件中,我包含 coscon 上下文。这是 extensions_custom.conf 的上下文:

[from-internal-custom]
exten => 1234,1,Playback(demo-congrats)  ; extensions can dial 1234
exten => 1234,2,Hangup()
exten => h,1,Hangup()
include => coscon

[coscon]
exten => **5,1,NoOp()
same => n,Answer()
exten => h,1,System(/usr/local/src/myscript.php)

现在,当我从软电话呼叫 **5 时,这是 Astrisk CLI 输出:

== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
    -- Executing [**5@from-internal:1] NoOp("SIP/102-00000035", "") in new stack
    -- Executing [**5@from-internal:2] Answer("SIP/102-00000035", "") in new stack
    -- Executing [**5@from-internal:3] Pickup("SIP/102-00000035","5&5@PICKUPMARK") in new stack
[2017-06-13 21:10:39] NOTICE[10676][C-00000035]: app_directed_pickup.c:302 pickup_exec: No target channel found for 5@from-internal.
[2017-06-13 21:10:39] NOTICE[10676][C-00000035]: app_directed_pickup.c:302 pickup_exec: No target channel found for 5@PICKUPMARK.
    -- Executing [**5@from-internal:4] Hangup("SIP/102-00000035", "") in new stack
    == Spawn extension (from-internal, **5, 4) exited non-zero on 'SIP/102-00000035'
    -- Executing [h@from-internal:1] Hangup("SIP/102-00000035", "") in new stack
    == Spawn extension (from-internal, h, 1) exited non-zero on 'SIP/102-00000035'

我认为来自内部上下文的默认 h 扩展正在执行,但我不知道如何覆盖它。

4

1 回答 1

2

您的问题如下:

假设你有 2 个上下文

[a]
exten => h,1,Noop(a)
exten => 1,1,Noop(1)
include => b
[b]
exten => h,1,Noop(b)
exten => 2,1,Noop(2)

如果您的上下文是 [a],它包括 [b],是的。但是如果扩展存在于 [a] 中,它将在 [a] 中执行,而不是在 [b] 中。所以 h 扩展将从 context[a] 执行。

如果你想要这项工作,你可以这样做:

   [b]
    exten =>h,1,Noop(b)
    exten => 2,1,Goto(${EXTEN},2); now even if included, you WILL BE in context b
    exten => 2,2,Noop(2);this one alway context b
于 2017-06-16T17:39:27.983 回答