From a6fe6f4014115301679685d21dcebdc6373c6837 Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Tue, 27 May 2025 03:22:09 +0300 Subject: [PATCH 1/8] Notify when update is available --- plugins/utilities.json | 14 ++++ plugins/utilities/update_notifier.py | 119 +++++++++++++++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 plugins/utilities/update_notifier.py diff --git a/plugins/utilities.json b/plugins/utilities.json index 737c4fb..c17d959 100644 --- a/plugins/utilities.json +++ b/plugins/utilities.json @@ -1842,6 +1842,20 @@ "md5sum": "ce2767d38676fda5be07d1608b80b5bb" } } + }, + "update_notifier": { + "description": "Notifies when a new update is available", + "external_url": "", + "authors": [ + { + "name": "brostosjoined", + "email": "", + "discord": "brostos" + } + ], + "versions": { + "1.0.0": null + } } } } \ 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..7b99032 --- /dev/null +++ b/plugins/utilities/update_notifier.py @@ -0,0 +1,119 @@ +# ba_meta require api 9 + +#! Crafted by brostos + +from platform import machine +import threading +import time +import webbrowser +import urllib.request +import re + +import babase +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 = match.group(1) + current_build_number = 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) + webbrowser.open(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) + webbrowser.open(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() From caf3d5737482f5837410514a8bc3f10c4cc32fdc Mon Sep 17 00:00:00 2001 From: brostosjoined <67740566+brostosjoined@users.noreply.github.com> Date: Tue, 27 May 2025 00:24:55 +0000 Subject: [PATCH 2/8] [ci] auto-format --- plugins/utilities/update_notifier.py | 37 +++++++++++++++------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/plugins/utilities/update_notifier.py b/plugins/utilities/update_notifier.py index 7b99032..c5e9e39 100644 --- a/plugins/utilities/update_notifier.py +++ b/plugins/utilities/update_notifier.py @@ -22,49 +22,50 @@ def threaded(func): 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: + 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 = match.group(1) current_build_number = babase.app.env.engine_build_number if latest_build_number == current_build_number: return - + pattern = r' {LIGHT_BLUE}{link}{RESET}") - + print( + f"{GREEN}Download the latest version using this official link-> {LIGHT_BLUE}{link}{RESET}") + # ba_meta export babase.Plugin class bybrostos(babase.Plugin): From c225d7067a7c7d12f81154cd79af0938010c5e4e Mon Sep 17 00:00:00 2001 From: brostosjoined <67740566+brostosjoined@users.noreply.github.com> Date: Tue, 27 May 2025 00:24:56 +0000 Subject: [PATCH 3/8] [ci] apply-version-metadata --- plugins/utilities.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/utilities.json b/plugins/utilities.json index c17d959..4eca1bf 100644 --- a/plugins/utilities.json +++ b/plugins/utilities.json @@ -1854,7 +1854,12 @@ } ], "versions": { - "1.0.0": null + "1.0.0": { + "api_version": 9, + "commit_sha": "caf3d57", + "released_on": "27-05-2025", + "md5sum": "c80dcc08fa6acaab036d457330b4279e" + } } } } From 893f18e3e6a680b8c33388154be72021cbce9075 Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Tue, 27 May 2025 15:31:59 +0300 Subject: [PATCH 4/8] use `bui.open_url` instead of `webbrowser.open` Check if build is from playstore --- plugins/utilities.json | 7 +------ plugins/utilities/update_notifier.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/utilities.json b/plugins/utilities.json index 4eca1bf..c17d959 100644 --- a/plugins/utilities.json +++ b/plugins/utilities.json @@ -1854,12 +1854,7 @@ } ], "versions": { - "1.0.0": { - "api_version": 9, - "commit_sha": "caf3d57", - "released_on": "27-05-2025", - "md5sum": "c80dcc08fa6acaab036d457330b4279e" - } + "1.0.0": null } } } diff --git a/plugins/utilities/update_notifier.py b/plugins/utilities/update_notifier.py index c5e9e39..3fa4065 100644 --- a/plugins/utilities/update_notifier.py +++ b/plugins/utilities/update_notifier.py @@ -5,11 +5,11 @@ from platform import machine import threading import time -import webbrowser import urllib.request import re import babase +import bauiv1 as bui import bascenev1 as bs @@ -83,6 +83,11 @@ def fetch_update(): extension = link.replace('https://files.ballistica.net/bombsquad/builds/', '') if build: if not ('server' in link_lower) and bs_platform.lower() in link_lower: + app = bui.app + subplatform = app.classic.subplatform + if subplatform == "google": + return + babase.screenmessage( "A new BombSquad version is available...\nRedirecting to download page", (0.21, 1.0, 0.20)) sound_sequence = [ @@ -101,7 +106,7 @@ def fetch_update(): time.sleep(delay) babase.pushcall(babase.Call(play_sound, sound), from_other_thread=True) time.sleep(1) - webbrowser.open(f'https://ballistica.net/downloads#:~:text={extension}') + 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" @@ -110,7 +115,7 @@ def fetch_update(): try: print(f"{GREEN}A new BombSquad version is available...Redirecting to download page{RESET}") time.sleep(4) - webbrowser.open(f'https://ballistica.net/downloads#:~:text={extension}') + 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}") From f16abc383e7a2e14387a408d1a6f970f061ea51c Mon Sep 17 00:00:00 2001 From: brostosjoined <67740566+brostosjoined@users.noreply.github.com> Date: Tue, 27 May 2025 12:34:57 +0000 Subject: [PATCH 5/8] [ci] auto-format --- plugins/utilities/update_notifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/utilities/update_notifier.py b/plugins/utilities/update_notifier.py index 3fa4065..e2bfaa2 100644 --- a/plugins/utilities/update_notifier.py +++ b/plugins/utilities/update_notifier.py @@ -87,7 +87,7 @@ def fetch_update(): subplatform = app.classic.subplatform if subplatform == "google": return - + babase.screenmessage( "A new BombSquad version is available...\nRedirecting to download page", (0.21, 1.0, 0.20)) sound_sequence = [ From ec866519e6f8f5120fa6a1103930ecdc9f6cb6e8 Mon Sep 17 00:00:00 2001 From: brostosjoined <67740566+brostosjoined@users.noreply.github.com> Date: Tue, 27 May 2025 12:34:59 +0000 Subject: [PATCH 6/8] [ci] apply-version-metadata --- plugins/utilities.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/utilities.json b/plugins/utilities.json index c17d959..d48d94a 100644 --- a/plugins/utilities.json +++ b/plugins/utilities.json @@ -1854,7 +1854,12 @@ } ], "versions": { - "1.0.0": null + "1.0.0": { + "api_version": 9, + "commit_sha": "f16abc3", + "released_on": "27-05-2025", + "md5sum": "6ba6b6510e0c2a98b817867f2fb62955" + } } } } From 4aca36757e6f5dd426cec8ddb5ca3d37b59e2d31 Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Tue, 27 May 2025 16:06:40 +0300 Subject: [PATCH 7/8] Ensure the build_numbers are of type `int` --- plugins/utilities.json | 7 +------ plugins/utilities/update_notifier.py | 4 ++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/plugins/utilities.json b/plugins/utilities.json index d48d94a..c17d959 100644 --- a/plugins/utilities.json +++ b/plugins/utilities.json @@ -1854,12 +1854,7 @@ } ], "versions": { - "1.0.0": { - "api_version": 9, - "commit_sha": "f16abc3", - "released_on": "27-05-2025", - "md5sum": "6ba6b6510e0c2a98b817867f2fb62955" - } + "1.0.0": null } } } diff --git a/plugins/utilities/update_notifier.py b/plugins/utilities/update_notifier.py index e2bfaa2..3a86783 100644 --- a/plugins/utilities/update_notifier.py +++ b/plugins/utilities/update_notifier.py @@ -39,8 +39,8 @@ def fetch_update(): match = re.search(r'(\d+)', web_content) if match: - latest_build_number = match.group(1) - current_build_number = babase.app.env.engine_build_number + 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 From 2b97e2c36f420383b0e9981188386c093a3e2c32 Mon Sep 17 00:00:00 2001 From: brostosjoined <67740566+brostosjoined@users.noreply.github.com> Date: Tue, 27 May 2025 13:09:05 +0000 Subject: [PATCH 8/8] [ci] apply-version-metadata --- plugins/utilities.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/utilities.json b/plugins/utilities.json index c17d959..d0a5c7e 100644 --- a/plugins/utilities.json +++ b/plugins/utilities.json @@ -1854,7 +1854,12 @@ } ], "versions": { - "1.0.0": null + "1.0.0": { + "api_version": 9, + "commit_sha": "4aca367", + "released_on": "27-05-2025", + "md5sum": "3ad8036b3491588bdc8a002803f2df58" + } } } }