Beispiel #1
0
        private void ParseResponse(string ircRawMessage)
        {
            //Console.WriteLine(ircRawMessage);

            foreach (string channelName in m_channelsJoined)
            {
                IRCParser.TwitchChannelMessageType channelMessageType = IRCParser.GetChannelMessageType(ircRawMessage, channelName);

                if (channelMessageType != IRCParser.TwitchChannelMessageType.None)
                {
                    HandleChannelMessage(ircRawMessage, channelName, channelMessageType);
                    return;
                }
            }

            IRCParser.TwitchMessageType twitchMessageType = IRCParser.GetNonChannelMessageType(ircRawMessage, Credentials.TwitchUsername);
            HandleNonChannelMessage(ircRawMessage, twitchMessageType);
        }
Beispiel #2
0
        private void HandleNonChannelMessage(string ircRawMessage, IRCParser.TwitchMessageType twitchMessageType)
        {
            switch (twitchMessageType)
            {
            case IRCParser.TwitchMessageType.Ping:
            {
                m_websocketClient.Send("PONG :tmi.twitch.tv");
                break;
            }

            case IRCParser.TwitchMessageType.Notice:
                break;

            case IRCParser.TwitchMessageType.WhisperMessage:
            {
                WhisperMessage whisperMessage = new WhisperMessage(ircRawMessage);
                OnWhisperMessageReceivedEventArgs whisperEvent = new OnWhisperMessageReceivedEventArgs(whisperMessage);
                OnWhisperMessageReceived?.Invoke(this, whisperEvent);
                break;
            }

            case IRCParser.TwitchMessageType.JoinedChannel:
            {
                string sChannel = ircRawMessage.Substring(ircRawMessage.IndexOf('#') + 1, ircRawMessage.IndexOf(" :") - ((ircRawMessage.IndexOf('#') + 1)));
                OnBotJoinedChannel?.Invoke(this, new OnBotJoinedChannelEventArgs(sChannel));
                m_channelsJoined.Add(sChannel);
                break;
            }

            case IRCParser.TwitchMessageType.LoginSuccessful:
            {
                // LOGIN SUCCESSFUL
                OnTwitchConnected?.Invoke();
                break;
            }

            case IRCParser.TwitchMessageType.LoginFailure:
            {
                // LOGIN FAILED
                OnTwitchLoginFailed?.Invoke();
                break;
            }
            }
        }