粘附的变量

发布于 2024-12-27 23:51:00 字数 109 浏览 2 评论 0原文

如何将变量传递到 daiplan.rb 文件。

拨打'SIP/976', :for => 15.seconds

我怎样才能做到这一点,以便我可以从文件外部指定扩展名。

How can I pass in a variable to the dailplan.rb file.

dial 'SIP/976', :for => 15.seconds

How can I make it so that I can specify the extension from outside the file.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心如荒岛 2025-01-03 23:51:00

我认为你只是在谈论 Ruby 字符串插值。制作拨号扩展变量的最简单方法是使用 Ruby:

myexten = '976'
dial "SIP/#{myexten}", :for => 15.seconds

如果要使用 #{} 将变量插入字符串,请记住使用双引号。

您可能还指的是 Asterisk 通道变量。假设我们正在讨论 Adhearsion 1.x,如果您想在拨号之前设置变量,请使用 #set_variable 语法:

set_variable 'MYVAR', "this is the value of the MYVAR channel variable"
set_variable 'OUTBOUND_GROUP', 'group1'
dial 'SIP/976', :for => 15.seconds

如果您想检索通道变量的值(例如作为 # 的结果而设置的值) dial) 你可以使用 get_variable:

dial 'SIP/976', :for => 15.seconds
ahn_log.info "Call completed with status #{get_variable 'DIALSTATUS'}"

I think you are just talking about Ruby string interpolation. The easiest way to make the dialed extension variable is to use Ruby:

myexten = '976'
dial "SIP/#{myexten}", :for => 15.seconds

Remember to use double quotes if you are going to use the #{} to insert a variable into the string.

You may also be referring to Asterisk channel variables. Assuming we are talking about Adhearsion 1.x, if you want to set a variable prior to the dial, use the #set_variable syntax:

set_variable 'MYVAR', "this is the value of the MYVAR channel variable"
set_variable 'OUTBOUND_GROUP', 'group1'
dial 'SIP/976', :for => 15.seconds

If you want to retrieve the value of a channel variable (such as those set as a result of the #dial) you can use get_variable:

dial 'SIP/976', :for => 15.seconds
ahn_log.info "Call completed with status #{get_variable 'DIALSTATUS'}"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文