-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
46 lines (40 loc) · 1.4 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
from bs4 import BeautifulSoup
import requests
import logging
logging.basicConfig(filename="bot.log", level=logging.INFO)
commit1 = "zero"
commit2 = ""
github_url = ""
print("Bot is running!")
while True:
###our github repository
url = "https://github.com/petrsvetr123lol/Filip-Test-Vektory/commits"
###beautiful soup stuff
result = requests.get(url)
doc = BeautifulSoup(result.text, "html.parser")
###finding latest commit - web scrapping
links = []
for link in doc.find_all('a', class_="Link--primary text-bold js-navigation-open markdown-title", href=True):
links.append(link['href'])
commit1 = links[0]
github_url = "https://github.com" + commit1
###if - commit was not sent...
if commit1 != commit2:
requests.post(
'https://api.telegram.org/bot5112690824:AAEwjrjQAxJtaWwyFDUa10pzltRBOAOqwS4/sendMessage?chat_id'
'=-604401103', data={
'text': github_url,
}).json()
commit2 = commit1
logging.info("Commit has been sent to the chat")
###else - commit was sent
"""
else:
requests.post(
'https://api.telegram.org/bot5112690824:AAEwjrjQAxJtaWwyFDUa10pzltRBOAOqwS4/sendMessage?chat_id'
'=-604401103', data={
'text': 'All commits were sent'
}).json()
###refresh eveery x seconds - default = 1800s
time.sleep(30)
"""