| Path: | README |
| Last Update: | Thu Mar 26 12:00:26 -0600 2009 |
This program/library creates Asterisk dialplans from ruby code.
rake install || ruby setup.rb --help | less
radp extensions.radp > extensions.conf asterisk -rx "extensions reload"
## This is an example of a "macro"
def mydial(*args)
n = Dial(args)
Congestion()
@p = n+101
Busy()
end
context :incoming do
ext :s do
n = Dial('SIP/sipura',20)
Answer()
Playback('chunky-bacon')
Hangup()
@p = n+101
Busy()
end
end
context :outgoing do
%w{800 866 877 888}.each do |x|
ext "_1#{x}NXXXXXX" do
mydial('ZAP/1/${EXTEN}')
end
end
ext('_NXXXXXX') { mydial('IAX2/NuFone/1505${EXTEN}') }
ext('_1NXXNXXXXXX') { mydial('IAX2/NuFone/1505${EXTEN}') }
ext '*' do VoiceMailMain() end
end
## vim: filetype=ruby
See the RADP class.
ext 's' { Answer(); Playback(tt-monkeys); Hangup() }
You must either use do...end or parenthesize the arguments, as in:
ext('s') { Answer(); Playback(tt-monkeys); Hangup() }
ext 's' do Answer(); Playback(tt-monkeys); Hangup(); end
Dial('ZAP/1,30')
Dial('ZAP/1', 30)
You can also use radp as a library, in which case it behaves a little differently (because it is not wrapped in an instance_eval). Simply treat it as a library and it will work as expected.
Copyright (C) 2005 Hans Fugal
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA