public DialogWindow() { InitializeComponent(); messageTextBox.PreviewKeyDown += MessageTextBox_PreviewKeyDown; chatListBox.DoubleClick += ChatListBox_DoubleClick; singleton = this; channelTextBox.Text = BotEntry.Channel; UsernameTextBox.Text = BotEntry.Config.Get <string>(Config.BotSetting.Username); Token = OAuthToken.Parse(BotEntry.Config.Get <string>(Config.BotSetting.SuperSecretSettings)); OATokenTextBox.Text = Token.AccessToken ?? string.Empty; botChannelTextBox.Text = BotEntry.ChatBotChannel.Value; BotEntry.NonCommandMessage += (IRCClient.ChannelMessageEventArgs msg) => { Actions.Add(() => { foreach (string s in CommandsListBox.Items) { var arr = s.Split('⇒'); if (arr[0][0] != '!') { if (msg.Message.ToLower().Contains('!' + arr[0].ToLower())) { string output = arr[1].Replace("{username}", msg.Badge.DisplayName); output = output.Replace("{channel}", msg.Channel); output = output.Replace("{message}", msg.Message); BotEntry.client.SendMessage(msg.Channel, output); Logger.Log($"[GENERIC] [{arr[0]}] command executed for |{msg.Badge.DisplayName}|"); } } else if (msg.Message.ToLower().Contains(arr[0].ToLower())) { string output = arr[1].Replace("{username}", msg.Badge.DisplayName); output = output.Replace("{channel}", msg.Channel); output = output.Replace("{message}", msg.Message); BotEntry.client.SendMessage(msg.Channel, output); Logger.Log($"[GENERIC] [{arr[0]}] command executed for |{msg.Badge.DisplayName}|"); } } }); }; BotEntry.client.RoomStateChanged += (s, b) => { Actions.Add(() => { if (BotEntry.client.CurrentChannelBadge != null && b == BotEntry.client.CurrentChannelBadge) { var areq = new JsonWebRequest <RoomModels>($"https://api.twitch.tv/kraken/chat/{BotEntry.client.CurrentChannelBadge.ChannelID}/rooms") { Method = HttpMethod.GET }; areq.AddHeader("Accept", "application/vnd.twitchtv.v5+json"); areq.AddHeader("Client-ID", "i5ezz567chrsv4rzal4l9q7kuuq9qv"); areq.AddHeader("Authorization", "OAuth 5egkvsbduc7frz4lbhyw4u239bv7sr"); areq.Finished += () => { //var str = areq.ResponseString; Actions.Add(() => { chatRoomsListBox.Items.Clear(); foreach (var it in areq.ResponseObject.Rooms) { chatRoomsListBox.Items.Add(it); } }); }; areq.Failed += (e) => { ExceptionExtensions.Rethrow(e); }; areq.PerformAsync(); } }); }; BotEntry.client.OnConnect += (s, e) => { Actions.Add(() => { connectionStateLabel.Text = $"Connected"; connectButton.Text = $"Disconnect"; connectButton.Enabled = true; this.Text = "Twitch bot API. State: [Connected]"; }); }; BotEntry.client.ConnectionClosed += (s, e) => { Actions.Add(() => { connectButton.Enabled = true; connectButton.Text = $"Connect"; connectionStateLabel.Text = "Disconnected"; this.Text = "Twitch bot API. State: Disconnected"; }); }; if (BotEntry.client.Connected) { connectionStateLabel.Text = $"Connected"; connectButton.Text = $"Disconnect"; connectButton.Enabled = true; this.Text = "Twitch bot API. State: [Connected]"; } }