forked from alebovic/textbank
-
Notifications
You must be signed in to change notification settings - Fork 1
/
messagessend.py
36 lines (28 loc) · 876 Bytes
/
messagessend.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
# -*- coding: utf-8 -*-
import csv
import time
import traceback
from subprocess import check_output
contacts="contacts.csv"
body = "body.txt"
with open(contacts, 'r') as f:
reader = csv.reader(f)
data = list(reader)
with open(body, 'r') as f:
message_body = f.read()
print(data)
print("Message body: " + message_body)
raw_input("Proceed? (enter to continue, ctrl-c to stop)")
for i in data:
if i[0] == "Name":
continue
try:
phone_number = i[1]
contact_name = i[0]
message = message_body.format(name=contact_name)
out = check_output(["osascript", "sendMessage.applescript", phone_number, message])
print("Texted " + contact_name + " at number " + phone_number)
except:
print("Failed to text " + contact_name + " at number " + phone_number)
traceback.print_exc()
time.sleep(10)