-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathtele_links.py
executable file
·56 lines (43 loc) · 1.29 KB
/
tele_links.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
import time
from datetime import datetime
from pathlib import Path
import schedule
from common.environment import GROUP_CHAT_ID
from common.tele_notifier import send_message_to_telegram
def send_link(website_url):
if website_url.startswith("#"):
return
try:
send_message_to_telegram(
website_url, disable_web_preview=False, override_chat_id=GROUP_CHAT_ID
)
except Exception as e:
print(f"Error processing: {website_url} - {str(e)}")
def main():
webpages = Path("webpages.txt").read_text().splitlines()
for webpage in webpages:
send_link(webpage)
def run():
now = datetime.now()
is_weekday = now.weekday() < 5
selected_hr = 7
before_open = now.time().hour == selected_hr
print(
"Checking {} - Hour: {} - Before Open - {}".format(
now, now.time().hour, before_open
)
)
if is_weekday and before_open:
print(
"{} - Is Weekday: {}, before_open: {}".format(now, is_weekday, before_open)
)
main()
def check_if_run():
print("Running {}".format(datetime.now()))
schedule.every(1).hour.do(run)
while True:
schedule.run_pending()
time.sleep(1 * 60 * 60) # every 1/2 hour
if __name__ == "__main__":
check_if_run()
# main()