From c80ddfacd97a0b85031511e799b2b2bb2a25279b Mon Sep 17 00:00:00 2001 From: Evan <17254809+bigun27@users.noreply.github.com> Date: Thu, 23 Jan 2025 00:07:07 -0500 Subject: [PATCH] Trash Twilio --- app/requirements.txt | 3 +- app/routes/client.py | 92 -------------------------------------------- 2 files changed, 1 insertion(+), 94 deletions(-) diff --git a/app/requirements.txt b/app/requirements.txt index 6d1dc93..421fbe9 100644 --- a/app/requirements.txt +++ b/app/requirements.txt @@ -1,5 +1,4 @@ Flask==3.1.0 flask_sqlalchemy==3.1.1 gunicorn==23.0.0 -prometheus-flask-exporter==0.23.1 -twilio==9.4.3 \ No newline at end of file +prometheus-flask-exporter==0.23.1 \ No newline at end of file diff --git a/app/routes/client.py b/app/routes/client.py index 0f6598a..7ed062f 100644 --- a/app/routes/client.py +++ b/app/routes/client.py @@ -1,5 +1,4 @@ from flask import jsonify, request -from twilio.twiml.voice_response import VoiceResponse, Gather from utils import logger, validate_data_presence, _get_weather, _get_cords, strq @@ -8,97 +7,6 @@ from . import routes as app from . import by_path_counter -@app.route("/voice", methods=["GET", "POST"]) -@by_path_counter -def voice(): - """Respond to incoming phone calls with a menu of options""" - # Start our TwiML response - resp = VoiceResponse() - - from_number = request.form["From"] - if from_number not in env_AUTHORIZED_CALLERS: - resp.say("You are calling from an unauthorized number. Goodbye.") - return str(resp) - - resp.say("Welcome to Atmo Assistant.") - # Start our verb - gather = Gather(num_digits=1, action="/gather") - gather.say( - "Main menu. Enter one for Asheboro. Two for Lynchburg. Three for Cullowhee. Zero for another zipcode." - ) - resp.append(gather) - - # If the user doesn't select an option, redirect them into a loop - resp.redirect("/voice") - - return str(resp) - - -@app.route("/gather", methods=["GET", "POST"]) -@by_path_counter -def gather(): - """Processes results from the prompt in /voice""" - # Start our TwiML response - resp = VoiceResponse() - - # If Twilio's request to our app included already gathered digits, - # process them - if "Digits" in request.values: - # Get which digit the caller chose - choice = request.values["Digits"] - - # a different message depending on the caller's choice - if choice == "1": - weather = _get_weather(35.6396, -79.8509) - resp.say(weather) - elif choice == "2": - weather = _get_weather(37.3490, -79.1787) - resp.say(weather) - elif choice == "3": - weather = _get_weather(35.3087, -83.1861) - resp.say(weather) - elif choice == "0": - custom = Gather(num_digits=5, action="/custom") - custom.say("Enter a zipcode for its weather.") - resp.append(custom) - else: - # If the caller didn't choose 1 or 2, apologize and ask them again - resp.say("Sorry, I don't understand that choice.") - - # If the user didn't choose 1 or 2 (or anything), send them back to /voice - resp.redirect("/voice") - - return str(resp) - - -@app.route("/custom", methods=["GET", "POST"]) -@by_path_counter -def custom(): - """Processes results from the prompt in /gather""" - # Start our TwiML response - resp = VoiceResponse() - - # If Twilio's request to our app included already gathered digits, - # process them - if "Digits" in request.values: - # Get which digit the caller chose - choice = request.values["Digits"] - - # a different message depending on the caller's choice - if len(choice) == 5: - weather = _get_weather(_get_cords(choice)) - resp.say(weather) - return str(resp) - else: - # If the caller didn't choose 1 or 2, apologize and ask them again - resp.say("Sorry, I don't understand that choice.") - - # If the user didn't choose 1 or 2 (or anything), send them back to /voice - resp.redirect("/voice") - - return str(resp) - - @app.route("/city", methods=["GET"]) @by_path_counter def city():