Created
August 28, 2008 21:22
-
-
Save vangberg/7830 to your computer and use it in GitHub Desktop.
never tested. might not work.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'dm-core' | |
require 'ftools' | |
incoming do | |
iv = new_instant_vox | |
iv.handle_call | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/components/instant_vox/lib/instant_vox.rb | |
class InstantVox | |
add_call_context :as => :call | |
def initialize | |
@sound_path = File.join(File.dirname(__FILE__), '../sounds') | |
@vox = Vox.create | |
end | |
def handle_call | |
call.hangup unless @user = User.get(:extension => call.extension) | |
record | |
menu | |
end | |
def record | |
call.play 'record-after-beep' | |
@tmp_vox = call.record | |
failure unless File.exists?(tmp_vox) | |
end | |
def menu | |
call.play 'menu' | |
case call.input(1, :timeout => 20.seconds) | |
when 1 | |
if File.move(@tmp_sound, File.join(@sound_path, "#{@vox.id}.gsm")) | |
goodbye | |
else | |
failure | |
end | |
when 2 | |
call.play @tmp_sound | |
menu | |
when 3 | |
record | |
menu | |
end | |
end | |
def failure | |
@vox.destroy | |
call.play 'failure' | |
call.hangup | |
end | |
def goodbye | |
call.play 'goodbye' | |
call.hangup | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment