-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.py
42 lines (37 loc) · 1.21 KB
/
helpers.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
import os
import requests
def getURLs ():
urls = dict()
urls.setdefault('NoKey', 'NoValue')
with open('.config', 'r') as f:
for line in f.readlines():
key = line.split(" ; ")[0]
value = line.split(" ; ")[1]
urls[key] = value
return urls
def getNotifiedId () -> list[str]:
notified = []
with open('notified_jobs.txt', 'r', encoding = 'utf-8') as f:
for _id in f.readlines():
notified.append(_id.rstrip('\n'))
return notified
def setNotifiedId (_id):
with open('notified_jobs.txt', 'a', encoding = 'utf-8') as f:
f.writelines(_id+'\n')
return True
def check_bot ():
response = requests.get("https://api.telegram.org/bot"+os.environ['TOKEN']+"/getMe")
if (response.status_code == 200):
return True
else:
return False
def notify (text):
response = requests.get("https://api.telegram.org/bot"+os.environ['TOKEN']+"/sendMessage",
params={
"chat_id": os.environ['CHAT'],
"text": text
})
if (response.status_code == 200):
return True
else:
return False