Skip to content

Instantly share code, notes, and snippets.

@RobSpectre
Created March 13, 2013 16:14
Show Gist options
  • Select an option

  • Save RobSpectre/5153675 to your computer and use it in GitHub Desktop.

Select an option

Save RobSpectre/5153675 to your computer and use it in GitHub Desktop.
Hacker Hotline by area of interest
@app.route('/caller', methods=['POST'])
def caller():
response = twiml.Response()
response.play("/static/sounds/intro.mp3")
with response.gather(numDigits=1, action='/handle-key', method='POST') as g:
g.say("Please press 0 for PHP, 1 for Java, 2 for C, C++, or Objective C, 3 for Ruby, 4 for Javascript or Jay Query, 5 for Python, 6 for dot Net, 7 for HTML or CSS, 8 for SQL, or 9 for other")
response.pause()
response.redirect('/caller')
return str(response)
# Method to handle input from the caller
@app.route('/handle-key', methods=['POST'])
def handle_key():
response = twiml.Response()
# Need to be able to access this in /wait
digit_pressed = int(request.values.get('Digits', None))
if digit_pressed in range(10):
response.say("You have chosen %s" % routes[digit_pressed])
# /rob - create url variable for the number pressed.
response.enqueue("Hacker Hotline", waitUrl='/wait/%s' % digit_pressed)
return str(response)
else:
return response.redirect('/caller')
# Create waiting room to notify user of current position in the queue and
# play the sweet, soothing sounds of Twilio's coffeeshop collection.
# /rob - Add handling for url variable for the digit pressed.
@app.route('/wait/<digit>', methods=['POST'])
def wait(digit):
response = twiml.Response()
response.say("You are number %s in line." % request.form['QueuePosition'])
response.play("http://demo.brooklynhacker.com/sounds/gangnamstyle.mp3")
response.redirect(url_for('.wait', _external=True))
if "client" in request.form['From']:
location = "the website"
else:
if request.form['FromCity']:
location = "%s, %s at %s" % (request.form['FromCity'],
request.form['FromState'], request.form['From'])
else:
location = "%s at %s" % (request.form['FromCountry'],
request.form['FromState'])
# /rob - Use map digit pressed to the area the hacker needs help with.
sendSmsToHackers("A hacker is calling from %s, and needs help with " %
routes[digit_pressed])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment