Example #1
0
        public static List <object> GetAvatars()
        {
            List <object> avatars = new List <object>();

            VRCToolsLogger.Info("getAvatars");

            if (!InitConnection())
            {
                return(avatars);
            }

            VRCTRequest request = new VRCTRequest("GET", "");

            VRCTResponse response = RequestSync(request.AsJson());

            if (response.returncode != ReturnCodes.SUCCESS)
            {
                if (response.returncode != ReturnCodes.BANNED_ACCOUNT && response.returncode != ReturnCodes.BANNED_ADDRESS)
                {
                    VRCToolsLogger.Error("Unable to get avatars: error code " + response.returncode);
                }
                return(avatars);
            }

            VRCToolsLogger.Info(response.data);
            List <SerializableApiAvatar> serializedAvatars = SerializableApiAvatar.ParseJson(response.data);

            foreach (SerializableApiAvatar serializedAvatar in serializedAvatars)
            {
                avatars.Add(serializedAvatar.getDictionary());
            }

            return(avatars);
        }
Example #2
0
        public static int AddAvatar(ApiAvatar apiAvatar)
        {
            if (!InitConnection())
            {
                return(-1);
            }

            SerializableApiAvatar avatar = new SerializableApiAvatar(
                apiAvatar.id,
                apiAvatar.name,
                apiAvatar.imageUrl,
                apiAvatar.authorName,
                apiAvatar.authorId,
                apiAvatar.assetUrl,
                apiAvatar.description,
                apiAvatar.tags,
                apiAvatar.version,
                apiAvatar.unityPackageUrl,
                apiAvatar.thumbnailImageUrl
                );


            VRCTResponse response = RequestSync(new VRCTRequest("ADD", avatar.AsJson()).AsJson());

            if (response.returncode != ReturnCodes.SUCCESS && response.returncode != ReturnCodes.AVATAR_ALREADY_IN_FAV)
            {
                if (response.returncode != ReturnCodes.BANNED_ADDRESS && response.returncode != ReturnCodes.BANNED_ACCOUNT)
                {
                    VRCToolsLogger.Error("Unable to add avatar to favorites: error " + response.returncode);
                }
                return(response.returncode);
            }
            VRCToolsLogger.Info("Avatar added to favorites sucessfully");
            return(ReturnCodes.SUCCESS);
        }
Example #3
0
        private static IEnumerator CheckAvatarOriginalReleaseStatus(string blueprintId, string id, string authorId)
        {
            VRCModLogger.Log("[AvatarStealerChecker] Checking avatar " + blueprintId);
            using (WWW avtrRequest = new WWW(API.GetApiUrl() + "avatars/" + blueprintId + "?apiKey=" + API.ApiKey))
            {
                yield return(avtrRequest);

                int rc = WebRequestsUtils.GetResponseCode(avtrRequest);
                if (rc == 200)
                {
                    try
                    {
                        VRCModLogger.Log("[AvatarStealerChecker] " + avtrRequest.text);
                        SerializableApiAvatar aa = JsonConvert.DeserializeObject <SerializableApiAvatar>(avtrRequest.text);
                        if (!aa.releaseStatus.Equals("public") && !aa.authorId.Equals(authorId))
                        {
                            VRCModLogger.Log("[AvatarStealerChecker] Avatar " + id + " is a private stealed avatar ! (" + blueprintId + ")");
                            checkedAvatars[id] = true;
                        }
                    }
                    catch (Exception e)
                    {
                        VRCModLogger.LogError("[AvatarStealerChecker] " + e.ToString());
                    }
                }
            }
        }