Code Monkey home page Code Monkey logo

Comments (5)

Katistic avatar Katistic commented on July 17, 2024

Hi,
I'm having an issue with the rewrite code where all users' location data comes back as None. They aren't in private worlds according to the VRChat website, however User.location, User.world_id, and User.instance_id are all None.

Any assistance in figuring this out would be greatly appreciated. The location information is primarily what I need here.

Thanks

EDIT: Here's the last portion of the user object I'm getting:

    'last_login': '2020-12-12T12:49:15.026Z',
    'status': 'active',
    'bio': '',
    'location': None,
    'bio_links': [],
    'state': 'online',
    'friend_key': '###REDACTED###',
    'world_id': None,
    'instance_id': None,
    'allow_avatar_copying': False

Thanks for reporting this!

It looks like I've accidentally created User instances (Which have world_id and instance_id as optional keys) instead of LimitedUser instances (which don't). When receiving a User object (not a LimitedUser init'd as a User) world_id and instance_id should be filled,

Other than that, I can't reproduce User.location returning None when it shouldn't. Can you send the User.raw of a User object that fails like this (don't forget to censor things you don't want people to see!)? Thanks :)

If after my next commit referencing this issue you stop receiving these errors, please close the issue :)

from vrchatpython.

CaptainDestructo avatar CaptainDestructo commented on July 17, 2024

I had no issues with the master branch, only the rewrite. I'm not sure if it's my code that's the issue, or if it's a bug in the API Wrapper, as there's not really much documentation to go off of.

Here's one of the objects I got back:

{
    'loop': <_UnixSelectorEventLoop running=True closed=False debug=False>,
    'client': <vrcpy.client.Client object at 0x7fa9093a9280>,
    'raw': {
        'id': 'usr_####################',
        'username': '##########',
        'displayName': '###########',
        'userIcon': 'https://api.vrchat.cloud/api/1/file/file_####################',
        'bio': '',
        'bioLinks': [],
        'currentAvatarImageUrl': 'https://api.vrchat.cloud/api/1/file/######################', 
        'currentAvatarThumbnailImageUrl': 'https://api.vrchat.cloud/api/1/image/###############',
        'fallbackAvatar': '#############',
        'status': 'active',
        'statusDescription': '###############',
        'state': 'online',
        'tags': [
            'system_world_access',
            'system_avatar_access',
            'system_trust_basic',
            'system_feedback_access',
            'system_trust_known',
            'system_trust_trusted',
            'language_nld',
            'language_eng',
            'system_supporter',
            'system_early_adopter',
            'system_trust_veteran'],
        'developerType': 'none',
        'last_login': '2020-12-12T12:49:15.026Z',
        'last_platform': 'standalonewindows',
        'allowAvatarCopying': False,
        'isFriend': True,
        'friendKey': '#################'},
    'username': '#######',
    'display_name': '##########',
    'id': '##############################',
    'avatar_image_url': 'https://api.vrchat.cloud/api/1/file/################',
    'avatar_thumbnail_url': 'https://api.vrchat.cloud/api/1/image/#############',
    'last_platform': 'standalonewindows',
    'tags': [
        'system_world_access',
        'system_avatar_access',
        'system_trust_basic',
        'system_feedback_access',
        'system_trust_known',
        'system_trust_trusted', 
        'language_nld', 
        'language_eng', 
        'system_supporter', 
        'system_early_adopter', 
        'system_trust_veteran'], 
    'developer_type': 'none',
    'is_friend': True,
    'status_description': '############',
    'last_login': '2020-12-12T12:49:15.026Z',
    'status': 'active',
    'bio': '',
    'location': None,
    'bio_links': [],
    'state': 'online',
    'friend_key': '##############',
    'world_id': None,
    'instance_id': None,
    'allow_avatar_copying': False
}

Here's the code I'm using:

import vrcpy
import asyncio
from termcolor import colored
from datetime import datetime

loop = asyncio.get_event_loop()
client = vrcpy.Client(loop=loop)

def printd(string):
    timestamp = (str(datetime.now().strftime("%d-%b-%Y (%H:%M:%S)")))
    string = colored(timestamp, 'magenta') + ' - ' + string
    print(string)


async def main(username, password):
    await client.login(
        username=username,
        password=password
    )

    try:
        # Start the ws event loop
        await client.start()
    except KeyboardInterrupt:
        await client.logout()

async def start(username, password):
    loop.create_task(main(username, password))


@client.event
async def on_friend_location(friend_b, friend_a):
    #printd(friend_a.__dict__)  # Used this for diagnosis
    printd("{} is now in {}#{}.".format(colored(friend_a.display_name, 'green'),
                                       colored(friend_a.location, 'yellow'), friend_a.instance_id))
    #                                "a private world" if friend_a.location is None else friend_a.location))


#@client.event
#async def on_friend_offline(friend_a):
#    printd("{} went offline.".format(colored(friend_a.display_name, 'green')))


@client.event
async def on_friend_active(friend_a):
    printd("{} is now {}.".format(colored(friend_a.display_name, 'green'), friend_a.state))


@client.event
async def on_friend_online(friend_a):
    printd("{} is now {}.".format(colored(friend_a.display_name, 'green'), colored(('online'), 'cyan')))


@client.event
async def on_friend_add(friend_b, friend_a):
    printd("{} is now your friend.".format(colored(friend_a.display_name, 'green')))


@client.event
async def on_friend_delete(friend_b, friend_a):
    printd("{} is no longer your friend.".format(colored(friend_a.display_name, 'green')))


#@client.event
#async def on_friend_update(friend_b, friend_a):
#    printd("{} has updated their profile/account.".format(colored(friend_a.display_name, 'green')))


#@client.event
#async def on_notification(notification):
#    printd("Got a {} notification from {}.".format(
#        notification.type, notification.senderUsername))


@client.event
async def on_connect():
    printd("Connected to wss pipeline.")


@client.event
async def on_disconnect():
    printd("Disconnected from wss pipeline.")

from vrchatpython.

Katistic avatar Katistic commented on July 17, 2024

As I said before, internally the wrapper was initializing LimitedUsers as Users, meaning they had keys they don't use (being instance_id and world_id). This is fixed now in 7efa947. There is nothing wrong with your code.

Though, as well, with the two examples you provided the users are "active" (User.status), meaning they aren't in game, and as such don't have a location.

The codeblock below is what your last replies object is built on. This is the raw json retrieved directly from VRC.
As this is a LimitedUser, it doesn't have, and will never have keys for world_id and instance_id.

'raw': { 'id': 'usr_####################', 'username': '##########', 'displayName': '###########', 'userIcon': 'https://api.vrchat.cloud/api/1/file/file_####################', 'bio': '', 'bioLinks': [], 'currentAvatarImageUrl': 'https://api.vrchat.cloud/api/1/file/######################', 'currentAvatarThumbnailImageUrl': 'https://api.vrchat.cloud/api/1/image/###############', 'fallbackAvatar': '#############', 'status': 'active', 'statusDescription': '###############', 'state': 'online', 'tags': [ 'system_world_access', 'system_avatar_access', 'system_trust_basic', 'system_feedback_access', 'system_trust_known', 'system_trust_trusted', 'language_nld', 'language_eng', 'system_supporter', 'system_early_adopter', 'system_trust_veteran'], 'developerType': 'none', 'last_login': '2020-12-12T12:49:15.026Z', 'last_platform': 'standalonewindows', 'allowAvatarCopying': False, 'isFriend': True, 'friendKey': '#################' },

EDIT:
Also note, location isn't being included in on_friend_location, I'm working to fix that now

from vrchatpython.

Katistic avatar Katistic commented on July 17, 2024

Reopen this issue if you have any more problems with this, thanks.

from vrchatpython.

CaptainDestructo avatar CaptainDestructo commented on July 17, 2024

from vrchatpython.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.