public stPage(string date, string date2, bool nightmodeset) { InitializeComponent(); if (nightmodeset == true) { Framelog.BackgroundColor = Color.Black; Framelog2.BackgroundColor = Color.Black; Framelog3.BackgroundColor = Color.Black; Framelog4.BackgroundColor = Color.Black; } api = new VRChatApi.VRChatApi(date, date2); usersset(); Device.StartTimer(TimeSpan.FromSeconds(3), () => { usersset(); return(false); }); }
public myavatar(string date, string date2) { userlist = new List <serwor>(); api = new VRChatApi.VRChatApi(date, date2); InitializeComponent(); OnButtonClicked(); }
public async Task <bool> VRCAPILogin(string username, string password) { Logger.Log("Trying to log in as", username, "..."); vrcapi = new VRChatApi.VRChatApi(username, password); me = await vrcapi.UserApi.Login().TimeoutAfter(TimeSpan.FromSeconds(5)); // var json = await me.Raw.Content.ReadAsStringAsync(); if (me == null) // && me.id == null // Check password { var confirmResult = MessageBox.Show($"Something went wrong while logging you in as {username}\n\nRetry?", "Failed to log in!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); if (confirmResult == DialogResult.Retry) { return(await VRCAPILogin(username, password)); } tabs_main.SelectTab(0); return(false); } Logger.Log("Logged in as", me.username); var _me = await vrcapi.UserApi.UpdateInfo(userId : me.id); // Logger.Trace("_me", _me.ToJson()); if (_me.id != null) { FillMe(); return(true); } return(false); /* TODO: FixMe * var json = await _me.Raw.Content.ReadAsStringAsync(); * object temp = null; * temp = Newtonsoft.Json.JsonConvert.DeserializeObject<UserResponse>(json); * var userResponse = (UserResponse)temp; * if (userResponse.id != null) { * Logger.Trace("userResponse", userResponse.ToJson()); * return true; * } else { * temp = Newtonsoft.Json.JsonConvert.DeserializeObject<BanResponse>(json); * var banResponse = (BanResponse)temp; * if (banResponse.Reason != null) * { * Logger.Trace("banResponse", banResponse.ToJson()); * var isIPban = banResponse.Target != me.displayName; * Logger.Trace("isIPban", isIPban); // https://stackoverflow.com/questions/3253701/get-public-external-ip-address * var confirmResult = MessageBox.Show($"Your account {banResponse.Target} has been banned by VRChat!\n\nExpires: {banResponse.ExpiresAt} ({banResponse.ExpiresIn.Humanize()} remaining.)\n\nReason: {banResponse.Reason.Quote()}\n\nDo you want to log in to another account?", "Account banned!", MessageBoxButtons.YesNo, MessageBoxIcon.Stop); * if (confirmResult == DialogResult.Yes) { SetupVRCApiAsync(); } * else { if (tabs_main.SelectedTab == tab_users) SetupUsers(); } * return false; * } else { * temp = Newtonsoft.Json.JsonConvert.DeserializeObject<Response>(json); TODO: Fix * var response = (Response)temp; * if (response.Content != null) { * Logger.Trace("response", response.ToJson()); * MessageBox.Show($"Failed to log in because of {response.Content}", "Failed to log in!", MessageBoxButtons.OK, MessageBoxIcon.Error); * return false; * } else { * Logger.Error("Unable to parse UpdateInfo response:", _me.Raw.ToJson()); * return false; * } * } * }*/ }
public moderatedpg2(string date, string date2) { InitializeComponent(); Moderlist = new List <moderate>(); api = new VRChatApi.VRChatApi(date, date2); set = true; usersset(); }
private void GotoMainWindow(VRChatApi.VRChatApi vrc) { var mainWin = new MainWindow(vrc); Application.Current.MainWindow = mainWin; this.Close(); mainWin.Show(); }
static async Task Main(string[] args) { using (WebClient wc = new WebClient()) { var online_users = wc.DownloadString("https://api.vrchat.cloud/api/1/visits"); Console.WriteLine("Initializing API... ({0} users online)", online_users); } api = new VRChatApi.VRChatApi("", ""); if (args.Length < 1) { worldId = SearchWorld(); if (string.IsNullOrWhiteSpace(worldId)) { throw new Exception("Missing world ID!"); } } else { worldId = args[0]; // wrld_b805006c-bec7-4179-958a-5a9351e48d5c } Console.WriteLine("Getting world \"{0}\"...", worldId); WorldResponse world = await api.WorldApi.Get(worldId); Console.WriteLine("Name: {0}", world.name); Console.WriteLine("Players: {0} / {1}", world.occupants, world.capacity); if (world.occupants < 1) { await CreateNew("No one seems to be online, sorry!"); return; } Console.WriteLine("Instances:"); string instance_pattern = @"^(\d+)~hidden"; //string instance_pattern_private = instance_pattern + @"\((usr_[\w\d]{8}-[\w\d]{4}-[\w\d]{4}-[\w\d]{4}-[\w\d]{12})\)~nonce\(([0-9A-Z]{64})\)$"; string fullest = ""; int fullest_count = 0; foreach (var instance in world.instances) { if (!Regex.Match(instance.id, instance_pattern).Success) { Console.WriteLine("{0}: {1}", instance.id, instance.occupants); if (instance.occupants > fullest_count) { fullest = instance.id; } fullest_count = instance.occupants; } /* else { * var parsed = Regex.Split(instance.id, instance_pattern_private); * var parsed_id = parsed[1];var parsed_usr_id = parsed[2]; var parsed_nonce = parsed[3]; * UserBriefResponse creator = await api.UserApi.GetById(parsed_usr_id); * Console.WriteLine("{0} (private) by {1}: {2}", parsed_id, creator.displayName, instance.occupants); * } */ } if (fullest_count < 1) { await CreateNew("No public instances found, sorry!"); return; } await StartGame(worldId, fullest); }
public ProfileWindow(VRChatApi.VRChatApi vrc, VRCUser user) { InitializeComponent(); Vm = (this.DataContext as ProfileVM); Vm.Vrc = vrc; Vm.User = user; }
public MainWindow(VRChatApi.VRChatApi vrc) { InitializeComponent(); Vm = (this.DataContext as MainVM); Vm.Vrc = vrc; Vm.UserChanged += Vm_UserChanged; trayIcon.Visible = true; trayIcon.Icon = Properties.Resources.icon; trayIcon.Text = this.Title; trayIcon.DoubleClick += new EventHandler((sender, arg) => this.Show()); }
public async Task <VRChatApi.VRChatApi> Login(string id, string pwd) { if (AutoLogin) { // Save login data. using (var bw = new BinaryWriter(new FileStream(LoginFile, FileMode.Create))) { bw.Write(id); byte[] pwdBytes = Encoding.UTF8.GetBytes(pwd); byte[] key = new byte[20]; using (var rng = new RNGCryptoServiceProvider()) { rng.GetBytes(key); } byte[] encryptedPwd = ProtectedData.Protect(pwdBytes, key, DataProtectionScope.CurrentUser); bw.Write(key.Length); bw.Write(key); bw.Write(encryptedPwd.Length); bw.Write(encryptedPwd); bw.Close(); } } // Auth API var vrc = new VRChatApi.VRChatApi(id, pwd); await vrc.RemoteConfig.Get(); // Login var loginResult = await vrc.UserApi.Login(); if (loginResult == null) { return(null); } return(vrc); }
public worRecent(string date, string date2) { userlist = new List <serwor>(); api = new VRChatApi.VRChatApi(date, date2); InitializeComponent(); OnButtonClicked(); BindingContext = this; listpro.ItemsSource = userlist; RefreshData(); listpro.IsRefreshing = false; }
public async Task <WorldInstanceResponse> GetInstance(VRChatApi.VRChatApi vrc, string worldId, string instanceId) { string key = worldId + "&" + instanceId; for (int retry = 0; retry < 3; ++retry) { try { var res = await vrc.WorldApi.GetInstance(worldId, instanceId); if (res != null) { lock (m_lockInstCache) { m_instCache[key] = res; } return(res); } } catch (Exception e) { Console.Error.WriteLine(e.Message); Console.Error.WriteLine(e.StackTrace); await Task.Delay(1000); } } lock (m_lockInstCache) { if (m_instCache.ContainsKey(key)) { return(m_instCache[key]); } } return(null); }
/// <summary> /// ログインを行う. /// </summary> public APIAdapter Login(string id = "", string password = "") { if (string.IsNullOrEmpty(id)) { id = ConfigData.UserName; } else { ConfigData.UserName = id; } if (string.IsNullOrEmpty(password)) { password = ConfigData.Password; } else { ConfigData.Password = password; } api = new VRChatApi.VRChatApi(id, password); return(this); }
public async Task <WorldResponse> GetWorld(VRChatApi.VRChatApi vrc, string id) { lock (m_lockCache) { if (m_cache.ContainsKey(id)) { return(m_cache[id]); } } for (int retry = 0; retry < 3; ++retry) { try { var res = await vrc.WorldApi.Get(id); if (res != null) { lock (m_lockCache) { m_cache[id] = res; } return(res); } } catch (Exception e) { Console.Error.WriteLine(e.Message); Console.Error.WriteLine(e.StackTrace); await Task.Delay(1000); } } return(null); }
public ChatWindow(VRChatApi.VRChatApi Vrcapi, UserResponse Me) { me = Me; vrcapi = Vrcapi; InitializeComponent(); }
public Viewpage(string date, string date2, bool nightmodeset) { try { float progress = 0f; bool refreshlimiter = true; // NavigationPage.SetHasNavigationBar(this, false); InitializeComponent(); userlist = new List <user>(); api = new VRChatApi.VRChatApi(date, date2); // usersset(); userlists(nightmodeset); userName = date; listpro.RefreshCommand = new Command(() => { if (refreshlimiter == false) { userlist.Clear(); userlists(nightmodeset); refreshlimiter = true; progress = 0; } else if (refreshlimiter == true) { var answer = DisplayAlert("Refresh Limiter", " Please try after 120 sec.", "ok"); } listpro.EndRefresh(); }); Device.StartTimer(TimeSpan.FromSeconds(5), () => { progress += 0.041666f; styledProgressBar.ProgressTo(progress, 750, Easing.Linear); return(true); }); Device.StartTimer(TimeSpan.FromSeconds(120), () => { refreshlimiter = false; /* * userlist.Clear(); * userlists(nightmodeset); */ return(true); }); } catch { } }
public ussearchpg(string date, string date2) { InitializeComponent(); api = new VRChatApi.VRChatApi(date, date2); }
public viewoffpage(string date, string date2) { try { // float progress = 0f; // NavigationPage.SetHasNavigationBar(this, false); InitializeComponent(); userlist = new List <user>(); api = new VRChatApi.VRChatApi(date, date2); // usersset(); userlists(); userName = date; listpro.RefreshCommand = new Command(() => { userlist.Clear(); userlists(); // progress = 0; // listpro.EndRefresh(); }); /* * * * * Device.StartTimer(TimeSpan.FromSeconds(5), () => * { * progress += 0.041666f; * * styledProgressBar.ProgressTo(progress, 750, Easing.Linear); * * * return true; * }); * */ Device.StartTimer(TimeSpan.FromSeconds(120), () => { userlist.Clear(); userlists(); //progress = 0; // listpro.EndRefresh(); return(true); }); } catch { var answer = DisplayAlert("login error", "Your session has expired. Please re-login", "ok"); } }