public TwitchChatConnection(IrcClient ircClient, bool isWhisperConnection) { this.ircClient = ircClient; this.ircClient.Connect(); if (isWhisperConnection) { ircClient.SendIrcString("CAP REQ :twitch.tv/commands"); } }
/// <summary> /// Logic for responding to chat events /// </summary> /// <param name="chatEvent"></param> private void RespondToEvent(Event chatEvent) { // Logic for responding to a "PING" event if (chatEvent.GetType().Equals(typeof(PingEvent))) { ircClient.SendIrcString("PONG"); Log.Message(chatEvent.ToString(), false); } // Logic for responding to a "PRIVMSG" event else if (chatEvent.GetType().Equals(typeof(ChatEvent))) { // Check all the chat roomms currently connected, then respond to the correct channel ChatEvent chatMessage = (ChatEvent)chatEvent; foreach (TwitchChatRoom chatroom in chatrooms) { if (chatMessage.Channel.Equals(chatroom.Channel.ChannelName)) { chatroom.RespondToEvent(chatEvent); break; } } } // Logic for responding to a "WHISPER" event else if (chatEvent.GetType().Equals(typeof(WhisperEvent))) { Log.Message(chatEvent.ToString(), true); } // Logic for responding to a "HOST" event else if (chatEvent.GetType().Equals(typeof(HostEvent))) { HostEvent hostData = (HostEvent)chatEvent; ircClient.SendChatMessage(hostData.Hostee, chatEvent.ToString()); Log.Message(hostData.ToString(), true); } // Logic for responding to an unknown event else { //Log.Message(chatEvent.ToString(), false); } }