-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrandma.py
56 lines (46 loc) · 1.33 KB
/
grandma.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from flask import Flask, request, redirect
import twilio.twiml
import random
app = Flask(__name__)
# Try adding your own number to this list!
callers = {
"+14158675309": "Curious George",
"+14158675310": "Boots",
"+14158675311": "Virgil",
}
WEATHER = [
'Are you wearing a jacket?',
'Sweetie, it\'s so chilly',
'Do you need an umbrella?',
'Are you wearing a hat?',
]
QUESTIONS = [
'Do you have a girlfriend/boyfriend?',
'Are you eating enough?',
'Do you have a job yet?',
'Where do you live again?',
'Do you have any friends?',
'Sweetie, what do you think of the fall of American democracy?',
'When are you going to graduate?',
'Are you coming to the church potluck on Saturday?',
]
RESPONSES = [
'That\'s so nice',
'You should call more',
'That\'s nice dear',
'Next time you visit we can make pies together',
'You look so frail all the time',
]
@app.route("/", methods=['GET', 'POST'])
def hello_monkey():
"""Respond and greet the caller by name."""
from_body = request.values.get('Body', None).lower()
if from_body == 'hi grandma':
message = 'ayyy'
else:
message = random.choice(QUESTIONS + RESPONSES)
resp = twilio.twiml.Response()
resp.message(message)
return str(resp)
if __name__ == "__main__":
app.run(debug=True)