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

Commit

Permalink
Attempt to fix #17
Browse files Browse the repository at this point in the history
  • Loading branch information
Katistic committed Oct 17, 2020
1 parent e23506c commit 8bedcaf
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions vrcpy/objects.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from vrcpy._hardtyping import *

from vrcpy.errors import IntegretyError
from vrcpy.errors import IntegretyError, GeneralError
from vrcpy import types

import asyncio
Expand Down Expand Up @@ -188,6 +188,11 @@ def __init__(self, client, obj=None):
"isFriend"
]

self.types.update({
"location": Location,
"instanceId": Location
})

if not obj == None:
self._assign(obj)
if not hasattr(self, "bio"):
Expand All @@ -203,11 +208,6 @@ def __init__(self, client, obj=None):
"allowAvatarCopying"
]

self.types.update({
"location": Location,
"instanceId": Location
})

if not obj == None:
self._assign(obj)

Expand Down Expand Up @@ -492,12 +492,20 @@ def __init__(self, client, location):
if ":" in location:
self.worldId, location = location.split(":")

if "~" in location:
self.name, t, nonce = location.split("~")
self.type, self.userId = t[:-1].split("(")
self.nonce = nonce.split("(")[1][:-1]
else:
self.name = location
originalLocation = location

try:
if "~" in location:
if location.count("~") == 2:
self.name, t, nonce = location.split("~")
self.type, self.userId = t[:-1].split("(")
self.nonce = nonce.split("(")[1][:-1]
elif location.count("~") == 1:
self.name, self.type = location.split("~") # Needs testing, https://github.com/vrchatapi/VRChatPython/issues/17
else:
self.name = location
except Exception as e: # https://github.com/vrchatapi/VRChatPython/issues/17
raise GeneralError("Exception occured while trying to parse location string ({})! Please open an issue on github! {}".format(originalLocation, e))


class Instance(BaseObject):
Expand Down

0 comments on commit 8bedcaf

Please sign in to comment.