-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcomms.py
More file actions
executable file
·65 lines (50 loc) · 1.58 KB
/
comms.py
File metadata and controls
executable file
·65 lines (50 loc) · 1.58 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
#!/usr/bin/python3
import configparser
from twilio.rest import TwilioRestClient
import smtplib
config = configparser.ConfigParser()
config.read("config.ini")
def sms(name, message):
name = name.lower()
accountSID = config['SMS']['accountSID']
authToken = config['SMS']['authToken']
twilioCli = TwilioRestClient(accountSID, authToken)
myTwilioNumber = config['SMS']['myTwilioNumber']
success = "Message sent to "
numbers = {}
for key in config['numbers']:
num = config['numbers'][key]
numbers.update({key:num})
print("SENDING MESSAGE")
number = numbers[name]
success += name
message = twilioCli.messages.create(body=message, from_=myTwilioNumber, to=number)
return success
def email(name, message):
name = name.lower()
success = "Email sent to "
emailadds = {}
for key in config['email']:
add = config['email'][key]
emailadds.update({key:add})
toadd = emailadds[name]
smtpadd = config['emailsettings']['smtpadd']
outemail = config['emailsettings']['outemail']
outemailpass = config['emailsettings']['outemailpass']
server = smtplib.SMTP(smtpadd)
server.ehlo()
server.starttls()
server.login(outemail, outemailpass)
msg = "\r\n".join([
"From: CHEYENNE.HOME",
"To: {}",
"Subject: MESSAGE FROM HOME",
"",
message,
]).format(toadd)
server.sendmail(outemail, toadd, msg)
success += name
return success
def call(name):
#COMMING SOON!
print("Dont't know how you got here :/")