-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunc.py
53 lines (41 loc) · 1.05 KB
/
func.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
from pymongo import MongoClient
from twilio.rest import Client
import os
from dotenv import load_dotenv
import re
load_dotenv()
account_sid = os.getenv("TWILIO_ACCOUNT_SID")
auth_token = os.getenv("TWILIO_AUTH_TOKEN")
# Create a Twilio client
sms = Client(account_sid, auth_token)
def send_SMS(TO, user):
message = f"{user} is feeling negative"
# Send the SMS message
message = sms.messages.create(
body=message,
from_='+1234567890',
to=TO
)
print(message.sid)
uri = os.getenv("MONGODB")
client = MongoClient(uri)
db = client['ListnerAI_DB']
collection = db['UserData']
def check_user_exists(user_id):
user = collection.find_one({'user_id': user_id})
if user:
return True
else:
return False
def is_valid_phone_number(phone_number):
pattern = re.compile(r'^\+\d{1,3}\d{10}$')
match = pattern.match(phone_number)
if match:
return True
else:
return False
def is_valid_name(name):
if len(name) > 0:
return True
else:
return False