Skip to content

Instantly share code, notes, and snippets.

@heftig
Created June 24, 2010 01:35
Show Gist options
  • Save heftig/450842 to your computer and use it in GitHub Desktop.
Save heftig/450842 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require "librevox"
require "sequel"
DB = Sequel.connect('postgres://postgres:leenuhks@localhost/freeswitch')
class Outbound < Librevox::Listener::Outbound
def session_initiated
answer
if authenticate then
main_menu
else
puts "Authentication failed, aborting"
end
done
end
def main_menu
dn = play_and_get_digits "tone_stream://%(10000,0,350,440)", "error.wav", :min => 1, :max => 11, :tries => 3
end
def authenticate
3.times do
pin = play_and_get_digits "conference/8000/conf-pin.wav", "error.wav", :min => 1, :max => 3
return true if DB[:cards].where(:pin => pin).first
puts "Invalid PIN."
end
return false
end
end
Librevox.start Outbound
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment