Skip to content
This repository was archived by the owner on Dec 20, 2021. It is now read-only.

Commit 79e2302

Browse files
committed
Fix some buggy bugs
1 parent 1534898 commit 79e2302

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

vrcpy/client.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ async def _ws_loop(self):
111111
auth = auth["token"]
112112

113113
self.ws = await self.request.session.ws_connect(
114-
"wss://pipeline.vrchat.cloud/?authToken="+auth,
115-
proxy=self.request.proxy)
114+
"wss://pipeline.vrchat.cloud/?authToken="+auth)
116115

117116
self.loop.create_task(self.on_connect())
118117

@@ -443,8 +442,13 @@ async def run():
443442
await self.login(username, password, mfa)
444443
await self.start()
445444

446-
self.loop.run_until_complete(run())
447-
self.loop.run_until_complete(self.logout())
445+
try:
446+
self.loop.run_until_complete(run())
447+
except KeyboardInterrupt as e:
448+
self.loop.run_until_complete(self.logout())
449+
except Exception as e:
450+
self.loop.run_until_complete(self.logout())
451+
raise e.__class__(str(e))
448452

449453
# Websocket Stuff
450454

vrcpy/request.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ async def _caller(self, method, path, *args, **kwargs):
2727
self.api_key = j["apiKey"]
2828

2929
if "params" in kwargs:
30-
if type(kwargs["params"][param]) == bool:
31-
kwargs["params"][param] = str(kwargs["params"][param]).lower()
30+
for param in kwargs["params"]:
31+
if type(kwargs["params"][param]) == bool:
32+
kwargs["params"][param] = str(kwargs["params"][param]).lower()
3233

3334
kwargs["params"]["apiKey"] = self.api_key
3435
else:
@@ -40,7 +41,7 @@ async def _caller(self, method, path, *args, **kwargs):
4041

4142
async def _call(self, method, path, *args, **kwargs):
4243
if self.session is None:
43-
self.session = aiohttp.ClientSession()
44+
self.session = aiohttp.ClientSession(headers={"user-agent": self.user_agent})
4445

4546
resp = None
4647
for attempt in range(self.request_retries + 1):
@@ -51,14 +52,14 @@ async def _call(self, method, path, *args, **kwargs):
5152
if type(e) in RequestErrors.errors + ClientErrors.errors:
5253
raise e.__class__(str(e))
5354

54-
if attempt == retries:
55+
if attempt == self.request_retries:
5556
raise RequestErrors.RequestError(
56-
"{} ({} retries)".format(e, retries)
57+
"{} ({} retries)".format(e, self.request_retries)
5758
)
5859

5960
return resp
6061

61-
async def close(self):
62+
async def close_session(self):
6263
await self.session.close()
6364

6465
async def get(self, path, *args, **kwargs):

0 commit comments

Comments
 (0)