-
Notifications
You must be signed in to change notification settings - Fork 0
/
notifier.py
32 lines (26 loc) · 1.05 KB
/
notifier.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
import smtplib
import googlevoice
from email.mime.text import MIMEText
class Notifier:
def __init__(self):
self.smtp_server = 'smtp.comcast.net'
self.from_email = '[email protected]'
with open('gvoicelogin.txt', 'r') as fin:
gvoice_email = fin.readline()
gvoice_password = fin.readline()
# TODO: Find a better way to initialize this.. sometimes it takes forever. Low priority.
self.voice = googlevoice.Voice()
self.voice.login(gvoice_email, gvoice_password)
# TODO: Complete email notifications.. Maybe send email from a specifically-created gmail account.
def send_email(self, email, crn):
body = 'Your course, ' + str(crn) + ' seems to be available, snatch it quickly!'
msg = MIMEText(body)
msg['Subject'] = 'VTCourseSearch: Availability Notification'
msg['From'] = self.from_email
msg['To'] = email
smtp = smtplib.SMTP(self.smtp_server)
smtp.sendmail(self.from_email, [email], msg)
smtp.close()
def send_text(self, phone, crn):
body = 'Your course: ' + str(crn) + ' is available!'
self.voice.send_sms(phone, body)