-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathlisten.py
More file actions
31 lines (28 loc) · 1.04 KB
/
listen.py
File metadata and controls
31 lines (28 loc) · 1.04 KB
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
from time import sleep
from datetime import datetime
import requests
session = requests.Session()
# session.proxies = {"http": "<PROXY>", "https": "<PROXY>"}
lastModified = None
while True:
try:
headers = {}
if lastModified:
headers['If-Modified-Since'] = lastModified
resp = session.head('https://piston-meta.mojang.com/mc/game/version_manifest.json', headers=headers)
if resp.status_code != 304:
lastModified = resp.headers.get('Last-Modified')
ret = session.post(
"https://api.github.com/repos/<USER>/<REPO>/actions/workflows/listen-mc-decompile.yml/dispatches",
headers={
"Accept": "application/vnd.github.v3+json",
"Authorization": "Bearer <TOKEN>",
},
data='{"ref": "master"}',
)
print(f"Manifest modified, call program at {datetime.now().isoformat()}")
sleep(360)
else:
sleep(60)
except Exception as e:
print(e)