-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathupdate_check.py
43 lines (33 loc) · 1.45 KB
/
update_check.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
## Github Update Checker
import TouchPortalAPI
import requests
import base64
from TPPEntry import PLUGIN_ID
#PLUGIN_NAME = "TikTokLive"
GITHUB_USER_NAME = "GitagoGaming"
GITHUB_PLUGIN_NAME = "TikTok-Live-Events--TouchPortal"
def plugin_update_check(plugin_version:str):
""" Checks Github for the latest version of the plugin
- Returns patchnotes on notification if there is a new version
"""
try:
github_check = TouchPortalAPI.Tools.updateCheck(GITHUB_USER_NAME, GITHUB_PLUGIN_NAME)
if github_check.replace('v','').replace(".","") > plugin_version:
### Pulling Patch Notes for Notification
try:
r = requests.get(f"https://api.github.com/repos/{GITHUB_USER_NAME}/{GITHUB_PLUGIN_NAME}/contents/recent_patchnotes.txt")
if r.status_code == 404:
print("No Patch Notes Found")
message = ""
else:
base64_bytes = r.json()['content'].encode('ascii')
message_bytes = base64.b64decode(base64_bytes)
message = message_bytes.decode('ascii')
except Exception as e:
message = ""
print("Error Plugin Update Check: ", e)
return github_check, message
else:
return False, False
except Exception as e:
print("Something went wrong checking update", e)