private bool Login(string authkey) { TwitchAuthenticatedClient tempClient = null; try { tempClient = new TwitchAuthenticatedClient(Globals.ClientId, authkey); } catch { return(false); } User user = tempClient.GetMyUser(); TwitchList <TwitchCSharp.Models.Stream> followed = tempClient.GetFollowedStreams(); if (user == null || IsNullOrWhiteSpace(user.Name)) { return(false); } MSG.Show("Your username " + user.Name, "Try again!", MessageBoxButton.OK, MessageBoxImage.Exclamation); Globals.Client = tempClient; Globals.Status.Username = user.Name; Globals.Status.Displayname = user.DisplayName; Globals.Authkey = authkey; if (!System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory + "AuthKey.txt")) { System.IO.File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "AuthKey.txt", Globals.Authkey); } return(true); }
private void btnUpdate_Click(object sender, RoutedEventArgs e) { if (client.GetMyUser().Partnered) { int streamDelay; try { streamDelay = Convert.ToInt32(tbStreamDelay.Text); if (streamDelay < 0 || streamDelay > 900) { throw new ArgumentOutOfRangeException(); } } catch (Exception) { streamDelay = 0; MessageBox.Show("Invalid delay given of 0 up to and including 900.\nDelay is will be reverted to 0 seconds.", "OakBot Channel Update", MessageBoxButton.OK, MessageBoxImage.Warning); } //client.Update(txtTitle.Text, cbGame.Text, Convert.ToString(streamDelay)); client.Update(txtTitle.Text, cbGame.Text, streamDelay); } else { client.Update(txtTitle.Text, cbGame.Text); } MessageBox.Show("Channel information updated!", "Oakbot Channel Update", MessageBoxButton.OK, MessageBoxImage.Asterisk); }
private bool LoginDirect() { TwitchAuthenticatedClient tempClient = null; try { tempClient = new TwitchAuthenticatedClient(Globals.ClientId, Globals.Authkey); } catch { MSG.Show("You auth key is invalid", "Try again!", MessageBoxButton.OK, MessageBoxImage.Exclamation); return(false); } User user = tempClient.GetMyUser(); if (user == null || IsNullOrWhiteSpace(user.Name)) { return(false); } MSG.Show("Connected as " + user.Name, "Success", MessageBoxButton.OK, MessageBoxImage.Exclamation); Globals.Client = tempClient; Globals.UserId = user.Id; Globals.Status.Username = user.Name; Globals.Status.Displayname = user.DisplayName; Scroll scroll = new Scroll(); scroll.Show(); this.Close(); return(true); }
private void ConnectStreamer() { try { streamerChat.Abort(); } catch (ThreadAbortException) { } catch (Exception) { } // Twitch Credentials accountStreamer = new TwitchCredentials(Config.StreamerUsername, Config.StreamerOAuthKey); // Start Streamer connection and login streamerChatConnection = new TwitchChatConnection(accountStreamer, false); streamerChatConnection.JoinChannel(Config.ChannelName); // Create threads for the chat connections streamerChat = new Thread(new ThreadStart(streamerChatConnection.Run)) { IsBackground = true }; // Start the chat connection threads streamerChat.Start(); // TODO check on success login/connection if (true) { // Disable Settings UI elements textBoxStreamerName.IsEnabled = false; buttonStreamerConnect.IsEnabled = false; cbAutoConnectStreamer.IsEnabled = false; btnStreamerConnect.Content = "Disconnect"; // Enable Twitch Dashboard tab tabMainDashboard.IsEnabled = true; try { client = new TwitchAuthenticatedClient(Config.StreamerOAuthKey, Config.TwitchClientID); txtTitle.Text = Utils.GetClient().GetMyChannel().Status; cbGame.Text = Utils.GetClient().GetMyChannel().Game; tbStreamDelay.Text = Utils.GetClient().GetMyChannel().Delay.ToString(); // Get Streamers Avatar using (WebClient wc = new WebClient()) { BitmapImage logo = new BitmapImage(); logo.BeginInit(); logo.StreamSource = wc.OpenRead(client.GetMyChannel().Logo); logo.CacheOption = BitmapCacheOption.OnLoad; logo.EndInit(); imgLogo.Source = logo; } // Enable partnered elements when partnered if (client.GetMyUser().Partnered) { // Stream delay tbStreamDelay.IsEnabled = true; // Manual Commercials gbManualCommercials.IsEnabled = true; } } catch (Exception ex) { Trace.TraceError(ex.ToString()); } } }