-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
59 lines (45 loc) · 1.53 KB
/
main.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
54
55
56
57
58
59
"""
Author: Jake Wachs
Date: 04/02/2020
Beacon - COVID-19 optimism bot
"""
from ml import trainModel, filterArticles, testmodel
from web import getArticleURLS
from util import craftMsg, sendEmails, logOutput
from web import checkRecoveries
import auth
import time
from datetime import date
if __name__ == '__main__':
# model, dataset, classification = trainModel()
'''
model, x_test, y_test = trainModel()
testmodel(model, x_test, y_test)
'''
'''
urls = getArticleURLS('optimistic news about coronavirus', 1)
positiveArticles = filterArticles(urls, model)
msg = craftMsg(positiveArticles)
sendEmails(auth.mailingList, msg)
'''
lastRecovered = checkRecoveries()
model, x_test, y_test = trainModel()
WAIT_TIME = 86400 # 24 hours
# WAIT_TIME = 600 # 10 minutes
while True:
currRecovered = checkRecoveries()
recoveredDifference = currRecovered - lastRecovered
# print('recovered difference', recoveredDifference)
emailSent = False
if recoveredDifference >= 10000:
lastRecovered = currRecovered
urls = getArticleURLS('optimistic news about coronavirus', 1)
positiveArticles = filterArticles(urls, model)
msg = craftMsg(positiveArticles)
try:
sendEmails(auth.mailingList, msg)
emailSent = True
except:
emailSent = False
logOutput(emailSent, recoveredDifference)
time.sleep(WAIT_TIME)