mirror of
https://github.com/bombsquad-community/plugin-manager.git
synced 2025-10-08 14:54:36 +00:00
[ci] auto-format
This commit is contained in:
parent
e17dccdaa9
commit
97885d7952
1 changed files with 58 additions and 71 deletions
|
|
@ -24,7 +24,7 @@ import threading
|
|||
import shutil
|
||||
import babase
|
||||
import _babase
|
||||
import bascenev1 as bs
|
||||
import bascenev1 as bs
|
||||
import bascenev1lib
|
||||
import bauiv1 as bui
|
||||
|
||||
|
|
@ -226,7 +226,7 @@ if not ANDROID:
|
|||
remove(path)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
# Make modifications for it to work on windows
|
||||
if babase.app.classic.platform == "windows":
|
||||
with open(Path(f"{getcwd()}/ba_data/python/pypresence/utils.py"), "r") as file:
|
||||
|
|
@ -250,24 +250,23 @@ def get_event_loop(force_fresh=False):
|
|||
return running
|
||||
else:
|
||||
return loop"""
|
||||
|
||||
|
||||
with open(Path(f"{getcwd()}/ba_data/python/pypresence/utils.py"), "w") as file:
|
||||
for number, line in enumerate(data):
|
||||
if number not in range(46,56):
|
||||
if number not in range(46, 56):
|
||||
file.write(line)
|
||||
get_module()
|
||||
|
||||
|
||||
from pypresence import PipeClosed, DiscordError, DiscordNotFound
|
||||
from pypresence.utils import get_event_loop
|
||||
import pypresence
|
||||
import pypresence
|
||||
import socket
|
||||
|
||||
|
||||
DEBUG = True
|
||||
|
||||
|
||||
_last_server_addr = 'localhost'
|
||||
_last_server_port = 43210
|
||||
|
||||
|
||||
def print_error(err: str, include_exception: bool = False) -> None:
|
||||
if DEBUG:
|
||||
if include_exception:
|
||||
|
|
@ -298,8 +297,8 @@ def get_event_loop(force_fresh=False):
|
|||
old_connect(*args, **kwargs)
|
||||
c = kwargs.get("address") or args[0]
|
||||
_last_server_port = kwargs.get("port") or args[1]
|
||||
|
||||
bs.connect_to_party = new_connect
|
||||
|
||||
bs.connect_to_party = new_connect
|
||||
|
||||
start_time = time.time()
|
||||
|
||||
|
|
@ -322,10 +321,10 @@ def get_event_loop(force_fresh=False):
|
|||
self._last_secret_update_time: float = 0
|
||||
self._last_connect_time: float = 0
|
||||
self.should_close = False
|
||||
|
||||
@staticmethod
|
||||
|
||||
@staticmethod
|
||||
def is_discord_running():
|
||||
for i in range(6463,6473):
|
||||
for i in range(6463, 6473):
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.settimeout(0.01)
|
||||
try:
|
||||
|
|
@ -333,11 +332,11 @@ def get_event_loop(force_fresh=False):
|
|||
s.close()
|
||||
if (conn == 0):
|
||||
s.close()
|
||||
return(True)
|
||||
return (True)
|
||||
except:
|
||||
s.close()
|
||||
return(False)
|
||||
|
||||
return (False)
|
||||
|
||||
def _generate_join_secret(self):
|
||||
# resp = requests.get('https://legacy.ballistica.net/bsAccessCheck').text
|
||||
connection_info = bs.get_connection_to_host_info()
|
||||
|
|
@ -394,7 +393,7 @@ def get_event_loop(force_fresh=False):
|
|||
self._subscribe("ACTIVITY_JOIN")
|
||||
self._subscribe("ACTIVITY_JOIN_REQUEST")
|
||||
|
||||
# def _update_presence(self) -> None:
|
||||
# def _update_presence(self) -> None:
|
||||
# self._last_update_time = time.time()
|
||||
# try:
|
||||
# self._do_update_presence()
|
||||
|
|
@ -403,7 +402,6 @@ def get_event_loop(force_fresh=False):
|
|||
# self._reconnect()
|
||||
# except Exception:
|
||||
# print_error("failed to update presence", include_exception= True)
|
||||
|
||||
|
||||
def _reconnect(self) -> None:
|
||||
self.rpc.connect()
|
||||
|
|
@ -480,7 +478,7 @@ def get_event_loop(force_fresh=False):
|
|||
def _connect_to_party(self, hostname, port) -> None:
|
||||
babase.pushcall(
|
||||
babase.Call(bs.connect_to_party, hostname, port), from_other_thread=True
|
||||
)
|
||||
)
|
||||
|
||||
def on_join_request(self, username, uid, discriminator, avatar) -> None:
|
||||
del uid # unused
|
||||
|
|
@ -508,10 +506,7 @@ class Discordlogin(PopupWindow):
|
|||
self.path = Path(f"{getcwd()}/token.txt")
|
||||
bg_color = (0.5, 0.4, 0.6)
|
||||
log_btn_colour = (0.10, 0.95, 0.10) if not self.path.exists() else (1.00, 0.15, 0.15)
|
||||
log_txt = "LOG IN" if not self.path.exists() else "LOG OUT"
|
||||
|
||||
|
||||
|
||||
log_txt = "LOG IN" if not self.path.exists() else "LOG OUT"
|
||||
|
||||
# creates our _root_widget
|
||||
PopupWindow.__init__(self,
|
||||
|
|
@ -520,7 +515,6 @@ class Discordlogin(PopupWindow):
|
|||
scale=(2.1 if _uiscale is babase.UIScale.SMALL else 1.5
|
||||
if _uiscale is babase.UIScale.MEDIUM else 1.0),
|
||||
bg_color=bg_color)
|
||||
|
||||
|
||||
self._cancel_button = bui.buttonwidget(
|
||||
parent=self.root_widget,
|
||||
|
|
@ -533,44 +527,38 @@ class Discordlogin(PopupWindow):
|
|||
autoselect=True,
|
||||
icon=bui.gettexture('crossOut'),
|
||||
iconscale=1.2)
|
||||
|
||||
|
||||
|
||||
bui.imagewidget(parent=self.root_widget,
|
||||
position=(180, self._height - 55),
|
||||
size=(32 * s, 32 * s),
|
||||
texture=bui.gettexture("discordLogo"),
|
||||
color=(10 - 0.32, 10 - 0.39, 10 - 0.96))
|
||||
|
||||
|
||||
|
||||
bui.imagewidget(parent=self.root_widget,
|
||||
position=(180, self._height - 55),
|
||||
size=(32 * s, 32 * s),
|
||||
texture=bui.gettexture("discordLogo"),
|
||||
color=(10 - 0.32, 10 - 0.39, 10 - 0.96))
|
||||
|
||||
self.email_widget = bui.textwidget(parent=self.root_widget,
|
||||
text="Email/Phone Number",
|
||||
size=(400, 70),
|
||||
position=(50, 180),
|
||||
h_align='left',
|
||||
v_align='center',
|
||||
editable=True,
|
||||
scale=0.8,
|
||||
autoselect=True,
|
||||
maxwidth=220)
|
||||
|
||||
|
||||
text="Email/Phone Number",
|
||||
size=(400, 70),
|
||||
position=(50, 180),
|
||||
h_align='left',
|
||||
v_align='center',
|
||||
editable=True,
|
||||
scale=0.8,
|
||||
autoselect=True,
|
||||
maxwidth=220)
|
||||
|
||||
self.password_widget = bui.textwidget(parent=self.root_widget,
|
||||
text="Password",
|
||||
size=(400, 70),
|
||||
position=(50, 120),
|
||||
h_align='left',
|
||||
v_align='center',
|
||||
editable=True,
|
||||
scale=0.8,
|
||||
autoselect=True,
|
||||
maxwidth=220)
|
||||
|
||||
|
||||
text="Password",
|
||||
size=(400, 70),
|
||||
position=(50, 120),
|
||||
h_align='left',
|
||||
v_align='center',
|
||||
editable=True,
|
||||
scale=0.8,
|
||||
autoselect=True,
|
||||
maxwidth=220)
|
||||
|
||||
bui.containerwidget(edit=self.root_widget,
|
||||
cancel_button=self._cancel_button)
|
||||
|
||||
cancel_button=self._cancel_button)
|
||||
|
||||
bui.textwidget(
|
||||
parent=self.root_widget,
|
||||
position=(265, self._height - 37),
|
||||
|
|
@ -581,7 +569,7 @@ class Discordlogin(PopupWindow):
|
|||
text="Discord",
|
||||
maxwidth=200,
|
||||
color=(0.80, 0.80, 0.80))
|
||||
|
||||
|
||||
bui.textwidget(
|
||||
parent=self.root_widget,
|
||||
position=(265, self._height - 78),
|
||||
|
|
@ -592,8 +580,7 @@ class Discordlogin(PopupWindow):
|
|||
text="💀Use at your own risk💀\n ⚠️discord account might get terminated⚠️",
|
||||
maxwidth=200,
|
||||
color=(1.00, 0.15, 0.15))
|
||||
|
||||
|
||||
|
||||
self._login_button = bui.buttonwidget(
|
||||
parent=self.root_widget,
|
||||
position=(120, 65),
|
||||
|
|
@ -658,8 +645,10 @@ class Discordlogin(PopupWindow):
|
|||
self.on_bascenev1libup_cancel()
|
||||
ws.close()
|
||||
|
||||
|
||||
|
||||
run_once = False
|
||||
|
||||
|
||||
def get_once_asset():
|
||||
global run_once
|
||||
if run_once:
|
||||
|
|
@ -687,6 +676,7 @@ def get_once_asset():
|
|||
pass
|
||||
run_once = True
|
||||
|
||||
|
||||
def get_class():
|
||||
if ANDROID:
|
||||
return PresenceUpdate()
|
||||
|
|
@ -707,7 +697,7 @@ class DiscordRP(babase.Plugin):
|
|||
|
||||
def on_app_running(self) -> None:
|
||||
if not ANDROID:
|
||||
self.rpc_thread.start()
|
||||
self.rpc_thread.start()
|
||||
self.update_timer = bs.AppTimer(
|
||||
1, bs.WeakCall(self.update_status), repeat=True
|
||||
)
|
||||
|
|
@ -742,13 +732,11 @@ class DiscordRP(babase.Plugin):
|
|||
# if Path(f"{getcwd()}/token.txt").exists():
|
||||
# threading.Thread(target=ws.run_forever, daemon=True, name="websocket").start()
|
||||
|
||||
|
||||
|
||||
def _get_current_activity_name(self) -> str | None:
|
||||
act = bs.get_foreground_host_activity()
|
||||
if isinstance(act, bs.GameActivity):
|
||||
return act.name
|
||||
|
||||
|
||||
this = "Lobby"
|
||||
name: str | None = (
|
||||
act.__class__.__name__.replace("Activity", "")
|
||||
|
|
@ -816,7 +804,7 @@ class DiscordRP(babase.Plugin):
|
|||
offlinename = json.loads(bs.get_game_roster()[0]["spec_string"])[
|
||||
"n"
|
||||
]
|
||||
if len(offlinename) > 19: # Thanks Rikko
|
||||
if len(offlinename) > 19: # Thanks Rikko
|
||||
self.rpc_thread.state = offlinename[slice(19)] + "..."
|
||||
else:
|
||||
self.rpc_thread.state = offlinename
|
||||
|
|
@ -829,7 +817,7 @@ class DiscordRP(babase.Plugin):
|
|||
self.rpc_thread.state = servername[slice(19)]
|
||||
|
||||
if connection_info == {}:
|
||||
self.rpc_thread.details = "Local" #! replace with something like ballistica github cause
|
||||
self.rpc_thread.details = "Local" # ! replace with something like ballistica github cause
|
||||
self.rpc_thread.state = self._get_current_activity_name()
|
||||
self.rpc_thread.party_size = max(1, len(roster))
|
||||
self.rpc_thread.party_max = max(1, bs.get_public_party_max_size())
|
||||
|
|
@ -842,7 +830,7 @@ class DiscordRP(babase.Plugin):
|
|||
bs.get_foreground_host_session()
|
||||
.__class__.__name__.replace("MainMenuSession", "")
|
||||
.replace("EndSession", "")
|
||||
.replace("FreeForAllSession", ": FFA") #! for session use small image key
|
||||
.replace("FreeForAllSession", ": FFA") # ! for session use small image key
|
||||
.replace("DualTeamSession", ": Teams")
|
||||
.replace("CoopSession", ": Coop")
|
||||
)
|
||||
|
|
@ -915,4 +903,3 @@ class DiscordRP(babase.Plugin):
|
|||
)
|
||||
if ANDROID and Path(f"{getcwd()}/token.txt").exists():
|
||||
self.rpc_thread.presence()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue