/// <summary> /// Adds a new account by the currently defined data /// </summary> private void AddAccount() { String Nick = textBoxNickname.Text; String OAuth = textBoxOAuth.Text; if (BotFile.GetAccountNames().Contains(Nick)) { int pos = -1; for (int i = 0; i < BotFile.GetAccountNames().Length; i++) { if (BotFile.GetAccountNames()[i] == Nick) { pos = i; break; } } if (pos < 0) { return; } // Update the oauth key BotFile.Accounts[pos].OAuth = OAuth; return; } else { TwitchAccount t = new TwitchAccount(Nick, OAuth); BotFile.AddAccount(t); RefreshAccounts(); } }
private void MainForm_Load(object sender, EventArgs e) { if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1) { MessageBox.Show("A instance of SoundInvoker are running", "SoundInvoker", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); return; } INSTANCE = this; audioITEM = Extensions.Load(); for (int i = 0; i < audioITEM.Count; i++) { AudioControl control = new AudioControl(); control.SetAudio(audioITEM[i]); flowLayoutPanel.Controls.Add(control); } optionsUI = new OptionsUI { options = Extensions.LoadOptions() }; account = Extensions.LoadAccount(); twitchOptions = new TwitchOptions(); if (account.auto_login) { TwitchLogin(); } splayer = new SoundPlayer(optionsUI.options.max_cache); listener = new KeyboardListener(); listener.KeyDown += Listener_KeyDown; listener.KeyUp += Listener_KeyUp; }
protected override void Init() { if (String.IsNullOrEmpty(CommandPrefix)) { CommandPrefix = "!"; } if (TextCommands == null) { TextCommands = new TextCommand[0]; } if (Accounts == null) { Accounts = new TwitchAccount[0]; } if (TwitchUsers == null) { TwitchUsers = new TwitchUser[0]; } if (String.IsNullOrEmpty(SubMessageNew)) { SubMessageNew = @"Thank you for the sub %name%! <3"; } if (String.IsNullOrEmpty(SubMessageResub)) { SubMessageResub = @"Thank you for the %months% sub, %name%! <3"; } if (String.IsNullOrEmpty(CoinName)) { CoinName = @"Coin(s)"; } }
public void AddAccount(TwitchAccount c) { List <TwitchAccount> a = Accounts.ToList(); a.Add(c); Accounts = a.ToArray(); }
public static void SaveAccount(TwitchAccount account) { using (StreamWriter file = File.CreateText($"account.json")) { JsonSerializer serializer = new JsonSerializer(); serializer.Serialize(file, account); } }
/// <summary> /// Tries to load an account. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonAccountsLoad_Click(object sender, EventArgs e) { try { TwitchAccount k = BotFile.Accounts[comboBoxAccounts.SelectedIndex]; this.textBoxNickname.Text = k.Nick; this.textBoxOAuth.Text = k.OAuth; } catch (Exception) { } }
// Accounts public void AddAccount(String Nick, String OAuth) { TwitchAccount c = new TwitchAccount(Nick, OAuth); AddAccount(c); }