-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspotfinder.py
More file actions
134 lines (118 loc) · 5.68 KB
/
spotfinder.py
File metadata and controls
134 lines (118 loc) · 5.68 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
from twilio import twiml
import nltk
from flask import Flask, request
import urllib2
from twilio.rest import TwilioRestClient
import requests
import pandas as pd
from collections import Counter
import smtplib
import requests
ACCOUNT_SID = "TWILIO_ACCOUNT_SID"
AUTH_TOKEN = "TWILIO_AUTH_TOKEN"
TWILIO_NUMBER = 'TWILIO_PH_NO'
client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
app = Flask(__name__)
@app.route("/")
def hello():
out_text = "Hi, How can i help you ?"
response = twiml.Response()
response.message(out_text)
return str(response)
@app.route("/sms", methods=['POST'])
def nursechat():
in_text = request.form["Body"]
ph_number = request.form["From"]
in_text = in_text.lower()
out_text = get_response(in_text)
response = twiml.Response()
response.message(out_text)
return str(response)
@app.route('/call', methods=['POST'])
def call():
# Make an outbound call to the provided number from your Twilio number
call = client.calls.create(to='+18574520056', from_=TWILIO_NUMBER,
url="http://demo.twilio.com/docs/voice.xml")
# Return a message indicating the call is coming
return 'Call coming in!'
def send_mail():
msg = MIMEMultipart()
msg['From'] = 'raxeshp1991@gmail.com'
msg['To'] = 'raxesh4you@gmail.com'
msg['Subject'] = "BENS REPORT"
msg.attach(MIMEText(file("sample.pdf").read()))
output_txt = "Bens latest data as on 03/27/2017 7:00 PM:\
\nBP = 122\
\nHR = 72\
\nWeight = 187 lb\
\nBlood Sugar = 130"
s = smtplib.SMTP('smtp.gmail.com', 587)
s.starttls()
s.login('raxeshp1991@gmail.com','sahajanand')
s.sendmail('raxeshp1991@gmail.com',['raxesh4you@gmail.com'], output_txt)
s.quit()
def find_seats(input_str):
red_val = requests.get("https://api.particle.io/v1/devices/3c0020000a47353137323334/red_val?access_token=79cecc0df866aeeabd18a68f2a7b32b33d54de03")
green_val = requests.get("https://api.particle.io/v1/devices/3c0020000a47353137323334/green_val?access_token=79cecc0df866aeeabd18a68f2a7b32b33d54de03")
yellow_val = requests.get("https://api.particle.io/v1/devices/3c0020000a47353137323334/yellow_val?access_token=79cecc0df866aeeabd18a68f2a7b32b33d54de03")
r_d = red_val.json()
g_d = green_val.json()
y_d = yellow_val.json()
if (y_d['result']) == 0 and (r_d['result'] == 0) and (g_d['result'] == 0):
output_txt = "Entire library is yours to conquer..!!"
elif (r_d['result']) == 0 and (g_d['result'] == 0):
output_txt = "Ther are 2 spots, one on 1st Floor on Green Couches and one on 2nd Floor on Red Couches"
elif (y_d['result']) == 0 and (g_d['result'] == 0):
output_txt = "Ther are 2 spots, one on 1st Floor on Green Couches and one on 2st Floor on Yellow couches"
elif (y_d['result']) == 0 and (r_d['result'] == 0):
output_txt = "Ther are 2 spots, one on 2st Floor on Yellow couches on left and other on Red Couches at the right"
elif r_d['result'] == 0:
output_txt = "There is 1 spot on 2nd Floor on Red Couches at the right end side of entrance"
elif g_d['result'] == 0:
output_txt = "There is 1 spot on 1st Floor on Green Couches at the very end"
elif y_d['result'] == 0:
output_txt = "There is a spot on 2st Floor on Yellow couches on the left side"
else:
output_txt = "Sorry, I could not find anything on 1st and 2nd Floor but you may find something on 3rd or 4th floor"
return output_txt
def get_response(input_st):
'''
Get the response output from input
'''
input_str = input_st.lower()
input_words = input_str.split()
red_val = requests.get("https://api.particle.io/v1/devices/3c0020000a47353137323334/red_val?access_token=79cecc0df866aeeabd18a68f2a7b32b33d54de03")
green_val = requests.get("https://api.particle.io/v1/devices/3c0020000a47353137323334/green_val?access_token=79cecc0df866aeeabd18a68f2a7b32b33d54de03")
yellow_val = requests.get("https://api.particle.io/v1/devices/3c0020000a47353137323334/yellow_val?access_token=79cecc0df866aeeabd18a68f2a7b32b33d54de03")
r_d = red_val.json()
g_d = green_val.json()
y_d = yellow_val.json()
# patients
all_w = ['find','spot']
greeting = ['hi']
if all(x in input_str for x in all_w):
if (y_d['result']) == 0 and (r_d['result'] == 0) and (g_d['result'] == 0):
output_txt = "Entire library is yours to conquer..!!"
elif (r_d['result']) == 0 and (g_d['result'] == 0):
output_txt = "Ther are 2 spots, one on 1st Floor on Green Couches and one on 2nd Floor on Red Couches"
elif (y_d['result']) == 0 and (g_d['result'] == 0):
output_txt = "Ther are 2 spots, one on 1st Floor on Green Couches and one on 2st Floor on Yellow couches"
elif (y_d['result']) == 0 and (r_d['result'] == 0):
output_txt = "Ther are 2 spots, one on 2st Floor on Yellow couches on left and other on Red Couches at the right"
elif r_d['result'] == 0:
output_txt = "There is 1 spot on 2nd Floor on Red Couches at the right end side of entrance"
elif g_d['result'] == 0:
output_txt = "There is 1 spot on 1st Floor on Green Couches at the very end"
elif y_d['result'] == 0:
output_txt = "There is a spot on 2st Floor on Yellow couches on the left side"
else:
output_txt = "Sorry, I could not find anything on 1st and 2nd Floor but you may find something on 3rd or 4th floor"
return output_txt
elif all(x in input_str for x in greeting):
output_txt = "Hi, This is your SpotFinder." + find_seats(input_str)
return output_txt
else:
output_txt = "You could try something like 'find me a spot' or 'spotfinder'"
return output_txt
if __name__ == "__main__":
app.run(debug=True)