Beispiel #1
0
        public async Task <UserSelfRES> UpdateInfo(string userId, string email = null, string birthday = null, string acceptedTOSVersion = null, List <string> tags = null)
        {
            JObject json = new JObject();

            if (email != null)
            {
                json["email"] = email;
            }

            if (birthday != null)
            {
                json["birthday"] = birthday;
            }

            if (acceptedTOSVersion != null)
            {
                json["acceptedTOSVersion"] = acceptedTOSVersion;
            }

            if (tags != null)
            {
                json["tags"] = JToken.FromObject(tags);
            }

            StringContent content = new StringContent(json.ToString(), Encoding.UTF8);

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            HttpResponseMessage response = await httpClient.PutAsync($"users/{userId}{apiKey}", content);

            UserSelfRES res = null;

            if (response.IsSuccessStatusCode)
            {
                var receivedJson = await response.Content.ReadAsStringAsync();

                res = JsonConvert.DeserializeObject <UserSelfRES>(receivedJson);

                Console.WriteLine($"{res.id}");
                Console.WriteLine($"Updated info from: {res.displayName}");
                Console.WriteLine();
            }

            return(res);
        }
Beispiel #2
0
        public async Task <UserSelfRES> Register(string username, string password, string email, string birthday = null, string acceptedTOSVersion = null)
        {
            JObject json = new JObject();

            json["username"] = username;
            json["password"] = password;
            json["email"]    = email;

            if (!string.IsNullOrEmpty(birthday))
            {
                json["birthday"] = birthday;
            }

            if (!string.IsNullOrEmpty(acceptedTOSVersion))
            {
                json["acceptedTOSVersion"] = acceptedTOSVersion;
            }

            StringContent content = new StringContent(json.ToString(), Encoding.UTF8);

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            HttpResponseMessage response = await httpClient.PostAsync($"auth/register{apiKey}", content);

            UserSelfRES res = null;

            if (response.IsSuccessStatusCode)
            {
                var receivedJson = await response.Content.ReadAsStringAsync();

                res = JsonConvert.DeserializeObject <UserSelfRES>(receivedJson);

                Console.WriteLine($"{res.id}");
                Console.WriteLine($"Registered as: {res.displayName}");
                Console.WriteLine();
            }
            else
            {
                inErrorState = true;
            }

            return(res);
        }
Beispiel #3
0
        public async Task MainAsync()
        {
            string username; string password;
            var    loginFile = new FileInfo("login.txt");

            if (loginFile.Exists)
            {
                Console.WriteLine($"Reading login info from {loginFile.Name}");
                var lines = File.ReadAllLines(loginFile.FullName);
                username = lines[0]; password = lines[1];
            }
            else
            {
                Console.WriteLine("Username:"******"Password:"******"Is banned");
                }

                if (inErrorState)
                {
                    await Task.Delay(3000);
                }
            }
            ConfigRES configRES = await client.Config.Get();

            if (!inErrorState)
            {
                if (!txt_path.Exists || !json_path.Exists)
                {
                    return;
                }
                var txt_avis = txt_path.ReadAllLines().ToList().Where(l => !string.IsNullOrWhiteSpace(l)).Select(l => l.Trim()).ToList();
                Console.WriteLine($"Read {txt_avis.Count} avatars from {txt_path.FullName.Quote()}");
                var json_avis = JsonConvert.DeserializeObject <List <SavedAvi> >(json_path.ReadAllText());
                Console.WriteLine($"Read {json_avis.Count} avatars from {json_path.FullName.Quote()}");
                foreach (var avi in txt_avis)
                {
                    try
                    {
                        var hasAvi = json_avis.Where(a => a.AvatarID == avi).FirstOrDefault();
                        if (hasAvi is null)
                        {
                            AvatarRES aRES = await client.Avatars.GetSingle(avi);

                            Console.WriteLine(aRES.ToJSON());
                            json_avis.Add(new SavedAvi()
                            {
                                Name = aRES.name, AvatarID = avi, ThumbnailImageUrl = aRES.thumbnailImageUrl
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                        json_avis.Add(new SavedAvi()
                        {
                            Name = avi, AvatarID = avi, ThumbnailImageUrl = ""
                        });
                        // Console.ReadLine();
                    }
                }
                json_avis = json_avis.OrderByDescending(a => a.Name).ToList();
                var json = JsonConvert.SerializeObject(json_avis, Formatting.Indented);
                Console.WriteLine(json);
                Console.ReadKey();
                json_path.WriteAllText(json);
            }
        }
Beispiel #4
0
        public async Task <UserSelfRES> Login()
        {
            string json = "";

            UserSelfRES userSelfRES = null;

            HttpResponseMessage res = await httpClient.GetAsync($"auth/user{apiKey}");

            json = await res.Content.ReadAsStringAsync();

            if (res.IsSuccessStatusCode)
            {
                userSelfRES  = JsonConvert.DeserializeObject <UserSelfRES>(json);
                currentUser  = userSelfRES;
                inErrorState = false;

                Console.WriteLine($"{userSelfRES.id}");
                Console.WriteLine($"Logged in as: {userSelfRES.displayName}");
                Console.WriteLine("");
            }
            else if (res.StatusCode == HttpStatusCode.Forbidden)
            {
                AuthModerationsRES authModerationsRES = JsonConvert.DeserializeObject <AuthModerationsRES>(json);
                inErrorState = true;

                if (json.ToLower().Contains("temporary ban"))
                {
                    Console.WriteLine($"Status: {res.StatusCode} --- {res.ReasonPhrase}");
                    Console.WriteLine($"message: {authModerationsRES.error["message"]}");
                    Console.WriteLine($"status_code: {authModerationsRES.error["status_code"]}");
                    Console.WriteLine();
                    Console.WriteLine($"Looks like you are banned!");
                    Console.WriteLine($"{authModerationsRES.target}");
                    Console.WriteLine($"{authModerationsRES.reason}");
                    Console.WriteLine($"{authModerationsRES.expires}");
                    Console.WriteLine();
                    isBanned = true;
                }
                else
                {
                    Console.WriteLine($"Status: {res.StatusCode} --- {res.ReasonPhrase}");
                    Console.WriteLine($"message: {authModerationsRES.error["message"]}");
                    Console.WriteLine($"status_code: {authModerationsRES.error["status_code"]}");
                    Console.WriteLine();
                }
            }
            else if (res.StatusCode == HttpStatusCode.Unauthorized)
            {
                BasicRES basicRES = JsonConvert.DeserializeObject <BasicRES>(json);
                Console.WriteLine($"Status: {res.StatusCode} --- {res.ReasonPhrase}");
                Console.WriteLine($"message: {basicRES.error["message"]}");
                Console.WriteLine($"status_code: {basicRES.error["status_code"]}");
                Console.WriteLine();
                inErrorState = true;
            }
            else
            {
                inErrorState = true;
                Console.WriteLine($"Unexpected Error! --- {res.StatusCode} --- {res.ReasonPhrase}");
                Console.WriteLine();
            }

            return(userSelfRES);
        }
Beispiel #5
0
        public async Task MainAsync()
        {
            Console.Title = "VRChatAPIdotNET";

            apiMenu = new List <string>()
            {
                "1. Grab Avatar by ID",
                "2. Grab Avatars",
                "3. Grab World by ID",
                "4. Grab Worlds",
                "5. Grab World Instance",
                "6. Grab World Metadata",
                "7. Grab User by ID",
                "8. Grab Users",
                "9. Grab User by name M1",
                "10. Grab User by name M2",
                "11. Grab Favorite by ID",
                "12. Grab Favorites",
                "13. Post new Favorite",
                "14. Grab Friends",
                "15. Send Friendrequest by ID",
                "16. Accept Friendrequest by ID",
                "17. Delete Friend by ID",
                "18. Grab Moderations",
                "19. Grab Moderations against other Users",
                "20. Grab Moderations against me",
                "21. Grab Notifications",
                "22. Send Invite",
                "23. Send Message",
                "24. Send Votekick M1",
                "25. Send Votekick M2",
                "26. Grab current VRChat Config",
                "27. Register an Account (obsolete)",
                "28. Update Accountinfo",
                "29. Get Discord Names",
                "Exit"
            };

            while (currentUser == null)
            {
                Console.Clear();

                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("If you are banned, please restart this program\nafter you're done looking at your moderations.\n");
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine(seperator);

                string username; string password;
                var    loginFile = new FileInfo("login.txt");
                if (loginFile.Exists)
                {
                    Console.WriteLine($"Reading login info from {loginFile.Name}");
                    var lines = File.ReadAllLines(loginFile.FullName);
                    username = lines[0]; password = lines[1];
                }
                else
                {
                    Console.WriteLine("Username:"******"Password:"******"{x.ip}\n{x.reason}\n{x.created}\n{x.expires}\n"); });
                }

                if (inErrorState)
                {
                    await Task.Delay(3000);
                }
            }

            Console.WriteLine(seperator);

            ConfigRES configRES = await client.Config.Get();

            Console.WriteLine(seperator);

            if (!inErrorState)
            {
                Console.WriteLine("Switching to Main Menu..");

                await Task.Delay(2500);

                Console.Clear();

                while (true)
                {
                    Console.Title = "VRChatAPIdotNET - Main Menu";
                    selected      = drawMenu(apiMenu);
                    if (selected == apiMenu[0])
                    {
                        await DoGetAvatarByID();
                    }
                    else if (selected == apiMenu[1])
                    {
                        await DoGetAvatars();
                    }
                    else if (selected == apiMenu[2])
                    {
                        await DoGetWorldByID();
                    }
                    else if (selected == apiMenu[13])
                    {
                        await DoGrabFriends();
                    }
                    else if (selected == apiMenu[26])
                    {
                        await DoRegisterAccount();
                    }
                    else if (selected == apiMenu[28])
                    {
                        await DoGetFriendsDiscord();
                    }
                    else if (selected == "Exit")
                    {
                        Environment.Exit(0);
                    }
                }
            }
        }