From 0db98e8618b8e5981ff284be365849ad8e8d3dd9 Mon Sep 17 00:00:00 2001 From: brostosjoined <67740566+brostosjoined@users.noreply.github.com> Date: Sun, 26 Jan 2025 17:40:01 +0000 Subject: [PATCH] [ci] auto-format --- plugins/utilities/discord_richpresence.py | 13 +++++-------- plugins/utilities/natpmp_upnp.py | 22 +++++++++++++--------- plugins/utilities/wave_emote.py | 14 ++++++++------ 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/plugins/utilities/discord_richpresence.py b/plugins/utilities/discord_richpresence.py index eb70ce8..5d27e7e 100644 --- a/plugins/utilities/discord_richpresence.py +++ b/plugins/utilities/discord_richpresence.py @@ -5,7 +5,7 @@ # ba_meta require api 9 #!"Made to you by @brostos & @Dliwk" # TODO -# - Update to the latest libs +# - Update to the latest libs # - Use account id to hash the tkn @@ -483,7 +483,7 @@ if not ANDROID: if sys.platform == "win32": asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy()) asyncio.set_event_loop(get_event_loop()) - + while not self.should_close: if time.time() - self._last_update_time > 0.1: self._do_update_presence() @@ -854,8 +854,6 @@ class Discordlogin(PopupWindow): PresenceUpdate().close() - - def get_class(): if ANDROID: return PresenceUpdate() @@ -901,7 +899,6 @@ class DiscordRP(babase.Plugin): if not ANDROID and self.rpc_thread.is_discord_running(): self.rpc_thread.rpc.close() self.rpc_thread.should_close = True - def on_app_pause(self) -> None: self.rpc_thread.close() @@ -981,12 +978,12 @@ class DiscordRP(babase.Plugin): if connection_info: hostname = socket.gethostname() local_ip = socket.gethostbyname(hostname) - + if bs.get_connection_to_host_info_2().address == local_ip: self.rpc_thread.details = "Local Server" else: self.rpc_thread.details = "Online" - + servername = connection_info.name self.rpc_thread.party_size = max( 1, sum(len(client["players"]) for client in roster) @@ -1054,7 +1051,7 @@ class DiscordRP(babase.Plugin): from bascenev1lib.game.thelaststand import TheLastStandGame from bascenev1lib.game.meteorshower import MeteorShowerGame from bascenev1lib.game.football import FootballCoopGame - from bascenev1lib.game.easteregghunt import EasterEggHuntGame + from bascenev1lib.game.easteregghunt import EasterEggHuntGame # noinspection PyUnresolvedReferences,PyProtectedMember try: diff --git a/plugins/utilities/natpmp_upnp.py b/plugins/utilities/natpmp_upnp.py index 9622195..0e3364f 100644 --- a/plugins/utilities/natpmp_upnp.py +++ b/plugins/utilities/natpmp_upnp.py @@ -93,7 +93,7 @@ def get_modules() -> None: } system = platform.platform() - + if "Windows" in system: packages["lxml"] = { "url": "https://files.pythonhosted.org/packages/36/88/684d4e800f5aa28df2a991a6a622783fb73cf0e46235cfa690f9776f032e/lxml-5.3.0-cp312-cp312-win32.whl", @@ -234,9 +234,10 @@ def get_modules() -> None: with zipfile.ZipFile(package_filename, "r") as zip_ref: zip_ref.extractall(install_path) try: - shutil.rmtree(Path(f"{install_path}/lxml-5.3.0.dist-info")) #! Remember to update accordingly + # ! Remember to update accordingly + shutil.rmtree(Path(f"{install_path}/lxml-5.3.0.dist-info")) except: - shutil.rmtree(Path(f"{install_path}/charset_normalizer-3.4.1.dist-info")) #! + shutil.rmtree(Path(f"{install_path}/charset_normalizer-3.4.1.dist-info")) # ! remove(package_path) else: return @@ -297,7 +298,10 @@ def play_sound(sound): with bs.get_foreground_host_activity().context: bs.getsound(sound).play() + accessible_online = None + + @threaded def confirm_port(): global accessible_online @@ -393,14 +397,14 @@ def add_port_mapping(): NewLeaseDuration=14400, ) babase.pushcall( - babase.Call(play_sound, "shieldUp"), - from_other_thread=True, - ) + babase.Call(play_sound, "shieldUp"), + from_other_thread=True, + ) except (SOAPError, HTTPError, UnicodeDecodeError): babase.screenmessage( "You will need to manualy port forward at the router :(" ) - babase.pushcall(babase.Call(play_sound, "error"),from_other_thread=True,) + babase.pushcall(babase.Call(play_sound, "error"), from_other_thread=True,) except ModuleNotFoundError: pass @@ -419,11 +423,11 @@ class Joinable(babase.Plugin): except ImportError: try: install_path = Path(f"{getcwd()}/ba_data/python") - shutil.rmtree(f"{install_path}/upnpy") + shutil.rmtree(f"{install_path}/upnpy") shutil.rmtree(f"{install_path}/natpmp") except FileNotFoundError: get_modules() - + def on_app_resume(self) -> None: confirm_port() add_port_mapping() diff --git a/plugins/utilities/wave_emote.py b/plugins/utilities/wave_emote.py index 13ea86a..a1d0da9 100644 --- a/plugins/utilities/wave_emote.py +++ b/plugins/utilities/wave_emote.py @@ -8,9 +8,10 @@ import bascenev1 as bs last_len_msg = 0 # Initialize the global variable outside the function + def wave_emote(): global last_len_msg # To modify the global variable - + # Check if the players are in game first try: act_players = bs.get_foreground_host_activity().players @@ -19,21 +20,21 @@ def wave_emote(): except AttributeError: # Except the attribute error if the player is in a server return - + # Incase chats are empty or in replay try: lastmsg = bs.get_chat_messages()[-1] except: return - - # Perform a check to see if the player is playing|spectating + + # Perform a check to see if the player is playing|spectating for player in act_players: try: if player.actor.node: continue except: return - + # Check if the message contains "hello" if len(bs.get_chat_messages()) != last_len_msg: if act_players and "hello" in lastmsg: @@ -46,6 +47,7 @@ def wave_emote(): print(last_len_msg, "last_len_msg") # ba_meta export plugin + + class brostos(babase.Plugin): timer = bs.AppTimer(0.5, wave_emote, repeat=True) -