Skip to content

Instantly share code, notes, and snippets.

@vangberg
Created August 28, 2008 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vangberg/7830 to your computer and use it in GitHub Desktop.
Save vangberg/7830 to your computer and use it in GitHub Desktop.
never tested. might not work.
require 'rubygems'
require 'dm-core'
require 'ftools'
incoming do
iv = new_instant_vox
iv.handle_call
end
# 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