Repository navigation
Expand file tree
/
Copy pathsms.py
More file actions
83 lines (67 loc) · 2.75 KB
/
Copy pathsms.py
File metadata and controls
83 lines (67 loc) · 2.75 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
import datetime
from twilio.rest import TwilioRestClient
from data import *
import sqlite3
account_sid = "AC0bf2297bcaf30f6542875aabfe7031c8" # Your Account SID from www.twilio.com/console
auth_token = "8222a02e66f12858eb48afad8f4b0f2b" # Your Auth Token from www.twilio.com/console
client = TwilioRestClient(account_sid, auth_token)
def sendMessage(body , to) :
message = client.messages.create(body=body,
to= to, # Replace with your phone number
from_="+14133845487") # Replace with your Twilio number
print(message.sid)
def sendBaby(chat_id):
conn = sqlite3.connect('example.db')
c = conn.cursor()
c.execute("SELECT * FROM subs WHERE chatid = ?" , [chat_id])
temp = c.fetchall()[0]
babyweek = temp[5]
mobile_no = temp[1]
for i in babydata :
if i >= babyweek :
write_baby( i, babyweek , mobile_no)
sendMessage("You have registered for New Born Baby Vaccination Schedule." , '+91' + str(mobile_no))
def write_baby(week , babyweek , mobile_no):
d = datetime.date.today()
diff = week - babyweek
t =datetime.timedelta(days=7*diff)
a = t+d
result_date = str(a.day) + '/' + str(a.month) + '/' + str(a.year)
file = open('messages.csv' , 'a')
file.write(result_date + ',' + str(mobile_no) + ',' + babydata[week] + '\n')
file.close()
def sendPreg(chat_id):
conn = sqlite3.connect('example.db')
c = conn.cursor()
c.execute("SELECT * FROM subs WHERE chatid = ?" , [chat_id])
temp = c.fetchall()[0]
pregweek = temp[3]
mobile_no = temp[1]
for i in pregdata :
if i >= pregweek :
write_preg( i, pregweek , mobile_no)
sendMessage("You have registered for Pregnancy Checkup Schedule." , '+91' + str(mobile_no))
def write_preg(week , pregweek , mobile_no):
d = datetime.date.today()
diff = week - pregweek
t =datetime.timedelta(days=7*diff)
a = t+d
result_date = str(a.day) + '/' + str(a.month) + '/' + str(a.year)
file = open('messages.csv' , 'a')
file.write(result_date + ',' + str(mobile_no) + ',' + pregdata[week] + '\n')
file.close()
def write_monthly(chat_id) :
conn = sqlite3.connect('example.db')
c = conn.cursor()
c.execute("SELECT * FROM subs WHERE chatid = ?" , [chat_id])
temp = c.fetchall()[0]
mobile_no = temp[1]
d = datetime.date.today()
for i in range(1,13):
t = datetime.timedelta(days=30*i)
a = t+d
result_date = str(a.day) + '/' + str(a.month) + '/' + str(a.year)
file = open('messages.csv' , 'a')
file.write(result_date + ',' + str(mobile_no) + ',' + "Reminder For Due Monthly Checkup By MEDIBOT" + '\n')
file.close()
sendMessage("You have registered for Monthly Regular Checkup Schedule." , '+91' + str(mobile_no))