Created
May 19, 2019 01:30
-
-
Save loganwilliams/a76dbed51fc3cdf8185dbaef9dc7e6f5 to your computer and use it in GitHub Desktop.
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
from flask import Flask, request | |
from twilio.twiml.voice_response import VoiceResponse | |
import random | |
from waitress import serve | |
app = Flask(__name__) | |
facts = [ | |
"A study conducted by a University of Florida researcher traces the existence of opossums as far back as the extinction of dinosaurs.", | |
"Due to an opossum's low body temperature and successful immune system, it's very rare for one to carry rabies.", | |
"In northern regions, opossums often have abnormally short tails - the ends are lost due to frostbite.", | |
"The Virginia opossum has more teeth than any other North American Mammal - 50, to be exact.", | |
"The Virginia opossum is the only marsupial that inhabits the U.S.", | |
"Opossums move around a lot. They typically live in hollow logs, rock crevices, pipes, attics, and beneath buildings.", | |
"Opossums are non-aggressive and non-destructive. They do not dig into the soil or destroy property. They will not harm people or pets.", | |
"Persimmons are one of the opossum's favorite foods during the long night." | |
] | |
@app.route("/answer", methods=['GET', 'POST']) | |
def answer_call(): | |
"""Respond to incoming phone calls with a brief message.""" | |
number = request.values.get('From')[2:] | |
resp = VoiceResponse() | |
if number == "2248777663": | |
resp.say("Welcome to the Possum Facts administrator menu. Say", voice='alice') | |
resp.play('http://fog.today/possummenu1.mp3') | |
resp.say("to add a fact. Say", voice='alice') | |
resp.play('http://fog.today/possummenu2.mp3') | |
resp.say("to update the flag. The current flag is NGW19{POGO_POSSUM}", voice='alice') | |
resp.pause(length=1) | |
resp.say("I'm sorry, I couldn't understand that. Please call back later.") | |
else: | |
resp.say("Thank you for calling Possum Facts! The number you are calling from, " + number + " is not associated with a Possum Facts account. Enjoy your free possum fact.", voice='alice') | |
resp.play('http://fog.today/possumhello.mp3') | |
fact = facts[random.randint(0, len(facts) - 1)] | |
resp.say(fact, voice='alice') | |
return str(resp) | |
if __name__ == "__main__": | |
serve(app, port=5000) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment