Example #1
0
        private void StartBotButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(options.botName) || string.IsNullOrEmpty(options.password) || string.IsNullOrEmpty(options.channelName) || string.IsNullOrEmpty(options.host) && options.port >= 1 && options.port <= 65535)
            {
                if (MessageBox.Show("It appears that the setup have blank fields. That is not allowed.", "Setup Required!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) == DialogResult.OK)
                {
                    SettingsButton_Click(null, EventArgs.Empty);
                    return;
                }
            }

            if (twitchBot == null)
            {
                twitchBot = new TwitchChatBot(this, options.host, options.port, options.botName, options.password, options.channelName, true);
                autoManager.StartThreads();
                if (twitchBot.twitchChat.Connected)
                {
                    StatusIndicator.BackColor = Color.Green;
                    StartBotButton.Text       = "Stop Bot";
                }
                else
                {
                    StatusIndicator.BackColor = Color.Red;
                    StartBotButton.Text       = "Start Bot";
                }
            }
            else
            {
                twitchBot.KillThreads();
                autoManager.KillThreads();

                if (twitchBot.twitchChat.Connected)
                {
                    StatusIndicator.BackColor = Color.Green;
                    StartBotButton.Text       = "Stop Bot";
                }
                else
                {
                    StatusIndicator.BackColor = Color.Red;
                    StartBotButton.Text       = "Start Bot";
                }

                twitchBot = null;
            }

            autoList_SelectedIndexChanged(null, EventArgs.Empty);

            GC.Collect();
        }