Example #1
0
        void ReadCallback(IAsyncResult asyncResult)
        {
            int    bytes   = SslStream.EndRead(asyncResult);
            string message = ReadMessage(bytes);

            if (message.Length > 0)
            {
                socketMessages.Put(message);

                ParseMessage(message);
            }
            Read();
        }
Example #2
0
        void OnCommand(IRCMessage message)
        {
            _ircMessages.Put(message.Cmd + " " + message.Args);

            switch (message.Cmd)
            {
            case "USERSTATE":
                if (message.Parameters.ContainsKey("mod") && message.Parameters["mod"] == "1")
                {
                    _messageInterval = 1;
                }
                else
                {
                    _messageInterval = 2;
                }
                break;

            case "PING":
                Send("PONG\n");
                break;

            case "376":
                if (ToolkitSettings.UseSeparateChatRoom && ToolkitSettings.ChatroomUUID != "" && ToolkitSettings.ChannelID != "")
                {
                    Send(
                        "CAP REQ :twitch.tv/membership\n" +
                        "CAP REQ :twitch.tv/tags\n" +
                        "CAP REQ :twitch.tv/commands\n" +
                        "JOIN #" + _channel + "\n" +
                        "JOIN #chatrooms:" + ToolkitSettings.ChannelID + ":" + ToolkitSettings.ChatroomUUID + "\n"
                        );
                }
                else
                {
                    Send(
                        "CAP REQ :twitch.tv/membership\n" +
                        "CAP REQ :twitch.tv/tags\n" +
                        "CAP REQ :twitch.tv/commands\n" +
                        "JOIN #" + _channel + "\n"
                        );
                }

                _socketReady = true;
                break;

            case "PRIVMSG":
                if (OnPrivMsg != null && !ToolkitSettings.WhisperCmdsOnly)
                {
                    OnPrivMsg.Invoke(message);
                }
                break;

            case "WHISPER":
                if (OnPrivMsg != null && ToolkitSettings.WhisperCmdsAllowed)
                {
                    message.Whisper = true;
                    OnPrivMsg.Invoke(message);
                }
                break;

            case "PONG":
                break;

            default:
                if (OnUnkwnMsg != null)
                {
                    OnUnkwnMsg.Invoke(message);
                }
                break;
            }
        }
Example #3
0
 public void Log(string message)
 {
     logBuffer.Put(message);
 }