You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RedditVideoMakerBot/utils/version.py

35 lines
1.2 KiB

import requests
from utils.console import print_step
# Set to the correct GitHub "owner/repo" for this fork, or leave empty to skip check.
_UPSTREAM_REPO = ""
def checkversion(__VERSION__: str):
if not _UPSTREAM_REPO:
return
try:
response = requests.get(
f"https://api.github.com/repos/{_UPSTREAM_REPO}/releases/latest",
timeout=10,
)
response.raise_for_status()
latestversion = response.json()["tag_name"]
except (requests.RequestException, KeyError, ValueError):
return # Network or API error — skip version check silently
if __VERSION__ == latestversion:
print_step(f"You are using the newest version ({__VERSION__}) of the bot")
elif __VERSION__ < latestversion:
print_step(
f"You are using an older version ({__VERSION__}) of the bot. "
f"Download the newest version ({latestversion}) from "
f"https://github.com/{_UPSTREAM_REPO}/releases/latest"
)
else:
print_step(
f"Welcome to the test version ({__VERSION__}) of the bot. "
f"Thanks for testing and feel free to report any bugs you find."
)