-
Notifications
You must be signed in to change notification settings - Fork 0
/
connect.py
54 lines (47 loc) · 1.87 KB
/
connect.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
import json
import db
import twilio_messaging as messaging
def is_connect_doctor(message):
if message.lower() == "connect to doctor":
return True
return False
def is_connect_community(message):
if message.lower() == "connect to community":
return True
return False
def is_connect_requested(message):
return (is_connect_doctor(message) or is_connect_community(message))
def connect(userID, message):
if is_connect_doctor(message):
doctor = db.findDoctor(userID)
if doctor:
db.setupConnection(userID, doctor)
messaging.send_message(userID, "We have connected you to a doctor")
messaging.send_message(doctor, "We have connected you to a user")
else:
messaging.send_message(userID, "No doctors are available")
elif is_connect_community(message):
community = db.findCommunity(userID)
if community:
db.setupConnection(userID, community)
messaging.send_message(userID, "We have connected you to a member")
messaging.send_message(community, "We have connected you to a user")
else:
messaging.send_message(userID, "No members are available")
def connect_expert(userID, type):
expert = db.findExpert(userID, type)
if expert:
db.setupConnection(userID, expert)
messaging.send_message(userID, "We have connected you to a "+type)
messaging.send_message(expert, "We have connected you to a user")
else:
messaging.send_message(userID, "No "+type+" is available")
return expert
def is_stop_requested(message):
if message.lower() == "disconnect":
return True
return False
def disconnect(user1, user2):
db.breakConnection(user1, user2)
messaging.send_message(user1, "You have been disconnected")
messaging.send_message(user2, "The other party disconnected")