|
1 | 1 | from vrcpy import Client, AClient, objects, aobjects |
2 | | -from vrcpy.errors import WebSocketError, WebSocketOpenedError |
| 2 | +from vrcpy.errors import WebSocketError, WebSocketOpenedError, IntegretyError |
3 | 3 | import threading |
4 | 4 | import websocket |
5 | 5 | import asyncio |
@@ -92,10 +92,19 @@ def _ws_friend_active(self, content): |
92 | 92 | self.on_friend_active(objects.User(self, content["user"])) |
93 | 93 |
|
94 | 94 | def _ws_friend_location(self, content): |
95 | | - world = objects.World(self, content["world"]) |
96 | 95 | user = objects.User(self, content["user"]) |
| 96 | + |
| 97 | + if content["location"] == "private": |
| 98 | + self.on_friend_location(user, None, None, None) |
| 99 | + return |
| 100 | + |
| 101 | + try: |
| 102 | + world = objects.World(self, content["world"]) |
| 103 | + except IntegretyError: |
| 104 | + world = self.fetch_world(content["world"]["id"]) |
| 105 | + |
| 106 | + instance = world.fetch_instance(content["instance"]) |
97 | 107 | location = objects.Location(self, content["location"]) |
98 | | - instance = objects.Instance(self, content["instance"]) |
99 | 108 |
|
100 | 109 | self.on_friend_location(user, world, location, instance) |
101 | 110 |
|
@@ -162,10 +171,19 @@ async def _ws_friend_active(self, content): |
162 | 171 | await self.on_friend_active(aobjects.User(self, content["user"])) |
163 | 172 |
|
164 | 173 | async def _ws_friend_location(self, content): |
165 | | - world = aobjects.World(self, content["world"]) |
166 | 174 | user = aobjects.User(self, content["user"]) |
| 175 | + |
| 176 | + if content["location"] == "private": |
| 177 | + await self.on_friend_location(user, None, None, None) |
| 178 | + return |
| 179 | + |
| 180 | + try: |
| 181 | + world = aobjects.World(self, content["world"]) |
| 182 | + except IntegretyError: |
| 183 | + world = await self.fetch_world(content["world"]["id"]) |
| 184 | + |
| 185 | + instance = await world.fetch_instance(content["instance"]) |
167 | 186 | location = aobjects.Location(self, content["location"]) |
168 | | - instance = aobjects.Instance(self, content["instance"]) |
169 | 187 |
|
170 | 188 | await self.on_friend_location(user, world, location, instance) |
171 | 189 |
|
|
0 commit comments