-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.py
42 lines (32 loc) · 1.25 KB
/
start.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
from urllib.parse import quote
import urllib3
import yaml
import time
import requests
from scrapper import initialize, check
def send(message, token, chat_id):
message_url = f"https://api.telegram.org/bot{token}/sendMessage?chat_id={chat_id}&text={quote(message)}"
requests.get(message_url)
if __name__ == '__main__':
with open('info.yaml', 'r') as file:
info = yaml.safe_load(file)
send("not değişim kontrol başlatıldı", info['token'], info['chat_id'])
driver = initialize(info['id'], info['password'], info['url'])
prev_lessons = []
while True:
try:
status, lessons, changes = check(driver, prev_lessons)
prev_lessons = lessons
if status:
message = ""
for change in changes:
lesson = change[0]
exam = change[1]
message += f'\nDers: {lesson}, Girilen sınav ve not: {exam} '
send("not değişimi algılandı: " + message, info['token'], info['chat_id'])
print("not değişimi algılandı: " + message)
else:
print("değişim yok")
except Exception as exc:
print(f'hata: {exc}')
time.sleep(info['interval'])