-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrun.py
54 lines (36 loc) · 1.35 KB
/
run.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
from actions import (add_announcements, add_stocks, publish_announcement,
publish_stock, remind_and_pin, unsent_announcements,
unsent_stocks, upcoming_stocks)
from utils.models import session
def publish_stocks():
# Fetch and store new stocks before
# publishing to the telegram channel
add_stocks()
unpublished_stocks = unsent_stocks()
if not unpublished_stocks:
return
for the_stock in unpublished_stocks:
publish_stock(the_stock)
session.commit()
return print(f"Published {len(unpublished_stocks)} Stocks")
def publish_announcements():
# Fetch and store new announcements before
# publishing to the telegram channel
add_announcements()
unpublished_announcements = unsent_announcements()
if not unpublished_announcements:
return
for announcement in unpublished_announcements:
publish_announcement(announcement)
session.commit()
return print(f"Published {len(unpublished_announcements)} Announcements")
def remind_stock():
upcoming_issues = list(upcoming_stocks())
if upcoming_issues:
for issue in upcoming_issues:
remind_and_pin(issue)
return print(f"Reminded about {len(upcoming_issues)} Stocks")
if __name__ == '__main__':
publish_stocks()
publish_announcements()
remind_stock()