diff --git a/plugins/utilities.json b/plugins/utilities.json index 737c4fb..d0a5c7e 100644 --- a/plugins/utilities.json +++ b/plugins/utilities.json @@ -1842,6 +1842,25 @@ "md5sum": "ce2767d38676fda5be07d1608b80b5bb" } } + }, + "update_notifier": { + "description": "Notifies when a new update is available", + "external_url": "", + "authors": [ + { + "name": "brostosjoined", + "email": "", + "discord": "brostos" + } + ], + "versions": { + "1.0.0": { + "api_version": 9, + "commit_sha": "4aca367", + "released_on": "27-05-2025", + "md5sum": "3ad8036b3491588bdc8a002803f2df58" + } + } } } } \ No newline at end of file diff --git a/plugins/utilities/update_notifier.py b/plugins/utilities/update_notifier.py new file mode 100644 index 0000000..3a86783 --- /dev/null +++ b/plugins/utilities/update_notifier.py @@ -0,0 +1,127 @@ +# ba_meta require api 9 + +#! Crafted by brostos + +from platform import machine +import threading +import time +import urllib.request +import re + +import babase +import bauiv1 as bui +import bascenev1 as bs + + +def threaded(func): + def wrapper(*args, **kwargs): + thread = threading.Thread( + target=func, args=args, kwargs=kwargs, name=func.__name__ + ) + thread.start() + + return wrapper + + +def play_sound(sound): + with bs.get_foreground_host_activity().context: + bs.getsound(sound).play() + + +@threaded +def fetch_update(): + url = 'https://ballistica.net/downloads' + try: + response = urllib.request.urlopen(url) + web_content = response.read().decode('utf-8') + except: + return + + match = re.search(r'(\d+)', web_content) + if match: + latest_build_number = int(match.group(1)) + current_build_number = int(babase.app.env.engine_build_number) + if latest_build_number == current_build_number: + return + + pattern = r' 0: + time.sleep(delay) + babase.pushcall(babase.Call(play_sound, sound), from_other_thread=True) + time.sleep(1) + bui.open_url(f'https://ballistica.net/downloads#:~:text={extension}') + elif not build: + if ('server' in link_lower) and bs_platform.lower() in link_lower: + GREEN = "\033[32m" + LIGHT_BLUE = "\033[94m" + RESET = "\033[0m" + try: + print(f"{GREEN}A new BombSquad version is available...Redirecting to download page{RESET}") + time.sleep(4) + bui.open_url(f'https://ballistica.net/downloads#:~:text={extension}') + except: + print( + f"{GREEN}Download the latest version using this official link-> {LIGHT_BLUE}{link}{RESET}") + + +# ba_meta export babase.Plugin +class bybrostos(babase.Plugin): + def on_app_running(self): + fetch_update()