mirror of
https://github.com/bombsquad-community/plugin-manager.git
synced 2025-11-07 17:36:00 +00:00
[ci] auto-format
This commit is contained in:
parent
037ee6e25c
commit
fbe8a1afb3
1 changed files with 104 additions and 123 deletions
|
|
@ -71,16 +71,15 @@ if ANDROID: # !can add ios in future
|
|||
from websocket import WebSocketConnectionClosedException
|
||||
import websocket
|
||||
|
||||
|
||||
start_time = time.time()
|
||||
|
||||
class PresenceUpdate:
|
||||
def __init__(self):
|
||||
self.ws = websocket.WebSocketApp("wss://gateway.discord.gg/?encoding=json&v=10",
|
||||
on_open=self.on_open,
|
||||
on_message=self.on_message,
|
||||
on_error=self.on_error,
|
||||
on_close=self.on_close)
|
||||
on_open=self.on_open,
|
||||
on_message=self.on_message,
|
||||
on_error=self.on_error,
|
||||
on_close=self.on_close)
|
||||
self.heartbeat_interval = int(41250)
|
||||
self.resume_gateway_url: str | None = None
|
||||
self.session_id: str | None = None
|
||||
|
|
@ -227,9 +226,6 @@ if ANDROID: # !can add ios in future
|
|||
self.ws.close()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if not ANDROID:
|
||||
# installing pypresence
|
||||
def get_module():
|
||||
|
|
@ -244,7 +240,7 @@ if not ANDROID:
|
|||
with open(filename, "rb") as f:
|
||||
content = f.read()
|
||||
assert hashlib.md5(content).hexdigest() == "f7c163cdd001af2456c09e241b90bad7"
|
||||
shutil.unpack_archive( filename, install_path)
|
||||
shutil.unpack_archive(filename, install_path)
|
||||
shutil.copytree(source_dir, file_path)
|
||||
shutil.rmtree(Path(f"{install_path}/pypresence-4.3.0"))
|
||||
remove(path)
|
||||
|
|
@ -274,12 +270,12 @@ def get_event_loop(force_fresh=False):
|
|||
return running
|
||||
else:
|
||||
return loop"""
|
||||
#Thanks Loup
|
||||
# Thanks Loup
|
||||
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)
|
||||
#fix the mess i did with the previous
|
||||
# fix the mess i did with the previous
|
||||
elif file_path.exists():
|
||||
with open(Path(f"{getcwd()}/ba_data/python/pypresence/utils.py"), "r") as file:
|
||||
data = file.readlines()
|
||||
|
|
@ -289,7 +285,6 @@ def get_event_loop(force_fresh=False):
|
|||
get_module()
|
||||
get_module()
|
||||
|
||||
|
||||
from pypresence import PipeClosed, DiscordError, DiscordNotFound
|
||||
from pypresence.utils import get_event_loop
|
||||
import pypresence
|
||||
|
|
@ -357,7 +352,7 @@ def get_event_loop(force_fresh=False):
|
|||
|
||||
@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:
|
||||
|
|
@ -365,10 +360,10 @@ 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
|
||||
|
|
@ -436,7 +431,6 @@ def get_event_loop(force_fresh=False):
|
|||
# except Exception:
|
||||
# print_error("failed to update presence", include_exception= True)
|
||||
|
||||
|
||||
def _reconnect(self) -> None:
|
||||
self.rpc.connect()
|
||||
self._subscribe_events()
|
||||
|
|
@ -520,7 +514,8 @@ def get_event_loop(force_fresh=False):
|
|||
babase.pushcall(
|
||||
babase.Call(
|
||||
bui.screenmessage,
|
||||
"Discord: {}{} wants to join!".format(username, discriminator if discriminator != "#0" else ""),
|
||||
"Discord: {}{} wants to join!".format(
|
||||
username, discriminator if discriminator != "#0" else ""),
|
||||
color=(0.0, 1.0, 0.0),
|
||||
),
|
||||
from_other_thread=True,
|
||||
|
|
@ -540,15 +535,13 @@ 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"
|
||||
self.code = False
|
||||
self.resp = "Placeholder"
|
||||
self.headers = {
|
||||
'user-agent': "Mozilla/5.0",
|
||||
'content-type': "application/json",
|
||||
}
|
||||
|
||||
|
||||
'user-agent': "Mozilla/5.0",
|
||||
'content-type': "application/json",
|
||||
}
|
||||
|
||||
# creates our _root_widget
|
||||
PopupWindow.__init__(self,
|
||||
|
|
@ -558,7 +551,6 @@ class Discordlogin(PopupWindow):
|
|||
if _uiscale is babase.UIScale.MEDIUM else 1.0),
|
||||
bg_color=bg_color)
|
||||
|
||||
|
||||
self._cancel_button = bui.buttonwidget(
|
||||
parent=self.root_widget,
|
||||
position=(25, self._height - 40),
|
||||
|
|
@ -571,42 +563,36 @@ class Discordlogin(PopupWindow):
|
|||
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))
|
||||
|
||||
|
||||
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,
|
||||
|
|
@ -630,7 +616,6 @@ class Discordlogin(PopupWindow):
|
|||
maxwidth=200,
|
||||
color=(1.00, 0.15, 0.15))
|
||||
|
||||
|
||||
self._login_button = bui.buttonwidget(
|
||||
parent=self.root_widget,
|
||||
position=(120, 65),
|
||||
|
|
@ -653,30 +638,26 @@ class Discordlogin(PopupWindow):
|
|||
bui.getsound('swish').play()
|
||||
self._transition_out()
|
||||
|
||||
|
||||
|
||||
def backup_2fa_code(self, tickt):
|
||||
if babase.do_once():
|
||||
self.email_widget.delete()
|
||||
self.password_widget.delete()
|
||||
|
||||
self.backup_2fa_widget = bui.textwidget(parent=self.root_widget,
|
||||
text="2FA/Discord Backup code",
|
||||
size=(400, 70),
|
||||
position=(50, 120),
|
||||
h_align='left',
|
||||
v_align='center',
|
||||
editable=True,
|
||||
scale=0.8,
|
||||
autoselect=True,
|
||||
maxwidth=220)
|
||||
|
||||
|
||||
text="2FA/Discord Backup code",
|
||||
size=(400, 70),
|
||||
position=(50, 120),
|
||||
h_align='left',
|
||||
v_align='center',
|
||||
editable=True,
|
||||
scale=0.8,
|
||||
autoselect=True,
|
||||
maxwidth=220)
|
||||
|
||||
json_data_2FA = {
|
||||
"code": bui.textwidget(query=self.backup_2fa_widget),
|
||||
"gift_code_sku_id": None,
|
||||
"ticket": tickt,
|
||||
"code": bui.textwidget(query=self.backup_2fa_widget),
|
||||
"gift_code_sku_id": None,
|
||||
"ticket": tickt,
|
||||
}
|
||||
|
||||
if json_data_2FA['code'] != "2FA/Discord Backup code":
|
||||
|
|
@ -719,8 +700,6 @@ class Discordlogin(PopupWindow):
|
|||
conn.request("POST", "/api/v9/auth/login", payload, self.headers)
|
||||
res = conn.getresponse().read()
|
||||
|
||||
|
||||
|
||||
try:
|
||||
token = json.loads(res)['token'].encode().hex().encode()
|
||||
with open(self.path, 'wb') as f:
|
||||
|
|
@ -732,7 +711,8 @@ class Discordlogin(PopupWindow):
|
|||
except KeyError:
|
||||
try:
|
||||
ticket = json.loads(res)['ticket']
|
||||
bui.screenmessage("Input your 2FA or Discord Backup code", (0.21, 1.0, 0.20))
|
||||
bui.screenmessage("Input your 2FA or Discord Backup code",
|
||||
(0.21, 1.0, 0.20))
|
||||
bui.getsound('error').play()
|
||||
self.resp = ticket
|
||||
self.backup_2fa_code(tickt=ticket)
|
||||
|
|
@ -749,7 +729,6 @@ class Discordlogin(PopupWindow):
|
|||
elif self.code == True:
|
||||
self.backup_2fa_code(tickt=self.resp)
|
||||
|
||||
|
||||
else:
|
||||
self.email_widget.delete()
|
||||
self.password_widget.delete()
|
||||
|
|
@ -761,6 +740,8 @@ class Discordlogin(PopupWindow):
|
|||
|
||||
|
||||
run_once = False
|
||||
|
||||
|
||||
def get_once_asset():
|
||||
global run_once
|
||||
if run_once:
|
||||
|
|
@ -788,6 +769,7 @@ def get_once_asset():
|
|||
pass
|
||||
run_once = True
|
||||
|
||||
|
||||
def get_class():
|
||||
if ANDROID:
|
||||
return PresenceUpdate()
|
||||
|
|
@ -913,7 +895,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
|
||||
|
|
@ -926,7 +908,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())
|
||||
|
|
@ -939,7 +921,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")
|
||||
)
|
||||
|
|
@ -1012,4 +994,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