コード例 #1
0
        public static async Task <FriendStatus> Friend(this VRCSharpSession session, APIUser User)
        {
            HttpClientHandler handler = null;
            HttpClient        client  = new HttpClient();

            if (session.UseProxies)
            {
                //Load proxies from Proxies.txt
                handler       = new HttpClientHandler();
                handler.Proxy = APIExtensions.GetRandomProxy();
                client        = new HttpClient(handler);
            }
            client.DefaultRequestHeaders.Clear();
            client.DefaultRequestHeaders.Add("Authorization", session.AuthToken);
            var payload = JsonConvert.SerializeObject(new FriendRequest()
            {
                _params = new FriendRequest.Params()
                {
                    userId = User.id
                }
            });
            var response = await client.PostAsync($"https://vrchat.com/api/1/user/{User.id}/friendRequest?apiKey={GlobalVars.ApiKey}", new StringContent(payload, Encoding.UTF8, "application/json"));

            if (response.StatusCode == HttpStatusCode.OK)
            {
                return(JsonConvert.DeserializeObject <FriendStatus>(await response.Content.ReadAsStringAsync()));
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
ファイル: APIWorld.cs プロジェクト: VRCMG/VRCSharp
        public static async Task <bool> Message(this VRCSharpSession session, APIUser user, string Message, string worldIdWithTags)
        {
            HttpClientHandler handler = null;
            HttpClient        client  = new HttpClient();

            if (session.UseProxies)
            {
                //Load proxies from Proxies.txt
                handler       = new HttpClientHandler();
                handler.Proxy = APIExtensions.GetRandomProxy();
                client        = new HttpClient(handler);
            }

            client.DefaultRequestHeaders.Clear();
            client.DefaultRequestHeaders.Add("Authorization", session.AuthToken);

            var payload = JsonConvert.SerializeObject(new InvitePayload()
            {
                message = "", type = "invite", details = new Details($"{session.Info.displayName} said: {Message}", worldIdWithTags)
            });

            var response = await client.PostAsync($"https://vrchat.com/api/1/user/{user.id}/notification?apiKey={GlobalVars.ApiKey}", new StringContent(payload, Encoding.UTF8, "application/json"));

            Console.WriteLine(payload.ToString());
            if (response.StatusCode == HttpStatusCode.OK)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        public static async Task <bool> Moderate(this VRCSharpSession session, APIUser user, ModerationType type)
        {
            HttpClientHandler handler = null;
            HttpClient        client  = new HttpClient();

            if (session.UseProxies)
            {
                //Load proxies from Proxies.txt
                handler       = new HttpClientHandler();
                handler.Proxy = APIExtensions.GetRandomProxy();
                client        = new HttpClient(handler);
            }
            client.DefaultRequestHeaders.Clear();
            client.DefaultRequestHeaders.Add("Authorization", session.AuthToken);
            var payload = JsonConvert.SerializeObject(new ModerationPayload()
            {
                moderated = user.id, type = type.Convert()
            });

            var response = await client.PostAsync($"https://vrchat.com/api/1/auth/user/playermoderations?apiKey={GlobalVars.ApiKey}&userId={user.id}", new StringContent(payload, Encoding.UTF8, "application/json"));

            if (response.StatusCode == HttpStatusCode.OK)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
        public static async Task <FriendRequestCancel> Unfriend(this VRCSharpSession session, APIUser User)
        {
            HttpClientHandler handler = null;
            HttpClient        client  = new HttpClient();

            if (session.UseProxies)
            {
                //Load proxies from Proxies.txt
                handler       = new HttpClientHandler();
                handler.Proxy = APIExtensions.GetRandomProxy();
                client        = new HttpClient(handler);
            }
            client.DefaultRequestHeaders.Clear();
            client.DefaultRequestHeaders.Add("Authorization", session.AuthToken);

            var response = await client.DeleteAsync($"https://vrchat.com/api/1/user/{User.id}/friendRequest?apiKey={GlobalVars.ApiKey}");

            if (response.StatusCode == HttpStatusCode.OK)
            {
                return(JsonConvert.DeserializeObject <FriendRequestCancel>(await response.Content.ReadAsStringAsync()));
            }
            else
            {
                return(null);
            }
        }
コード例 #5
0
        private async Task Start()
        {
            try
            {
                //LoadProxies();
                Console.Title = "VRCSharp Test";

                VRCSharpSession session = new VRCSharpSession("Username", "Password", false);
                session.OnAttemptedLogin += Session_OnAttemptedLogin;

                await session.Login();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            await Task.Delay(-1);
        }
コード例 #6
0
ファイル: APIWorld.cs プロジェクト: VRCMG/VRCSharp
        public static async Task <APIWorld> GetAPIWorldByID(this VRCSharpSession session, string WorldID)
        {
            HttpClientHandler handler = null;
            HttpClient        client  = new HttpClient();

            if (session.UseProxies)
            {
                //Load proxies from Proxies.txt
                handler       = new HttpClientHandler();
                handler.Proxy = APIExtensions.GetRandomProxy();
                client        = new HttpClient(handler);
            }
            client.DefaultRequestHeaders.Clear();
            client.DefaultRequestHeaders.Add("Authorization", session.AuthToken);

            var response = await client.GetAsync($"https://vrchat.com/api/1/worlds/{WorldID}?apiKey={GlobalVars.ApiKey}");

            return(JsonConvert.DeserializeObject <APIWorld>(await response.Content.ReadAsStringAsync()));
        }
コード例 #7
0
ファイル: APIExtensions.cs プロジェクト: VRCMG/VRCSharp
        public async static Task <List <APIUser> > GetFriends(this VRCSharpSession session, bool MustBeOffline = false, int Index = 50, int Offset = 300)
        {
            HttpClientHandler handler = null;
            HttpClient        client  = new HttpClient();

            if (session.UseProxies)
            {
                //Load proxies from Proxies.txt
                handler       = new HttpClientHandler();
                handler.Proxy = APIExtensions.GetRandomProxy();
                client        = new HttpClient(handler);
            }

            client.DefaultRequestHeaders.Clear();
            client.DefaultRequestHeaders.Add("Authorization", session.AuthToken);

            var response = await client.GetAsync($"https://vrchat.com/api/1/auth/user/friends?offline={MustBeOffline}&n={Index}&offset={Offset}&apiKey={GlobalVars.ApiKey}");

            return(JsonConvert.DeserializeObject <List <APIUser> >(await response.Content.ReadAsStringAsync()));
        }
コード例 #8
0
ファイル: APIWorld.cs プロジェクト: VRCMG/VRCSharp
        public static async Task <bool> VoteKick(this VRCSharpSession session, APIUser User)
        {
            if (APIWorldHelper.CurrentWorldID == null)
            {
                Console.WriteLine("I can't votekick if you haven't made me join a world!");
                return(false);
            }
            else
            {
                HttpClientHandler handler = null;
                HttpClient        client  = new HttpClient();

                if (session.UseProxies)
                {
                    //Load proxies from Proxies.txt
                    handler       = new HttpClientHandler();
                    handler.Proxy = APIExtensions.GetRandomProxy();
                    client        = new HttpClient(handler);
                }

                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Add("Authorization", session.AuthToken);
                var payload = JsonConvert.SerializeObject(new VoteKickPayload()
                {
                    worldId = APIWorldHelper.CurrentWorldID, instanceId = APIWorldHelper.CurrentInstanceID.ToString()
                });
                Console.WriteLine(payload.ToString());
                var response = await client.PostAsync($"https://vrchat.com/api/1/user/{User.id}/votekick?apiKey={GlobalVars.ApiKey}", new StringContent(payload, Encoding.UTF8, "application/json"));

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
コード例 #9
0
ファイル: APIWorld.cs プロジェクト: VRCMG/VRCSharp
        public static async Task <bool> VisitWorld(this VRCSharpSession session, APIWorld World, int InstanceID)
        {
            var nvc = new List <KeyValuePair <string, string> >();

            nvc.Add(new KeyValuePair <string, string>("userId", "asd"));
            nvc.Add(new KeyValuePair <string, string>("worldId", $"{World.id}:{InstanceID.ToString()}"));
            var req = new HttpRequestMessage(HttpMethod.Put, "https://vrchat.com/api/1/visits")
            {
                Content = new FormUrlEncodedContent(nvc)
            };

            HttpClientHandler handler = null;
            HttpClient        client  = new HttpClient();

            if (session.UseProxies)
            {
                //Load proxies from Proxies.txt
                handler       = new HttpClientHandler();
                handler.Proxy = APIExtensions.GetRandomProxy();
                client        = new HttpClient(handler);
            }
            client.DefaultRequestHeaders.Clear();
            client.DefaultRequestHeaders.Add("Authorization", session.AuthToken);


            var response = await client.SendAsync(req);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                APIWorldHelper.CurrentWorldID    = World.id;
                APIWorldHelper.CurrentInstanceID = InstanceID;
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #10
0
 private void Session_OnAttemptedLogin(VRCSharpSession session, string message)
 {
     Console.WriteLine("Tried to login! Result: " + message);
 }