コード例 #1
0
        void Client_RawMessageReceived(object sender, IrcRawMessageEventArgs e)
        {
            if (e.Message.Command == "010")
            {
                Client.Disconnect();
                Connect("irc2.speedrunslive.com", Username, Password);
                return;
            }

            if (e.Message.Command == "433")
            {
                NicknameInUse?.Invoke(this, null);
            }

            if (e.Message.Source != null &&
                e.Message.Source.Name == "NickServ" &&
                e.Message.Command == "NOTICE")
            {
                if (e.Message.Parameters[1] == "Password accepted - you are now recognized.")
                {
                    Task.Factory.StartNew(() =>
                    {
                        foreach (var channel in ChannelsToJoin)
                        {
                            Client.Channels.Join(channel);
                        }
                    });
                }
                else if (e.Message.Parameters[1] == "Password incorrect.")
                {
                    PasswordIncorrect?.Invoke(this, null);
                }
            }

            if (e.Message.Command == "NOTICE" &&
                e.Message.Source != null &&
                e.Message.Source.Name == "RaceBot" &&
                e.Message.Parameters.Count > 1)
            {
                var text = e.Message.Parameters[1];
                if (text != null && !text.Contains("#srl"))
                {
                    MessageReceived?.Invoke(this, new Tuple <string, SRLIRCUser, string>(RaceChannelName, new SRLIRCUser("RaceBot", SRLIRCRights.Operator), text));
                }
            }

            RawMessageReceived?.Invoke(this, $"{e.Message.Command} - {e.Message.Parameters.Where(x => x != null).Aggregate((a, b) => a + " " + b)}");
        }
コード例 #2
0
        void Client_RawMessageReceived(object sender, IrcRawMessageEventArgs e)
        {
            if (e.Message.Command == "010")
            {
                Client.Disconnect();
                Connect("irc2.speedrunslive.com", Username, Password);
                return;
            }

            if (e.Message.Command == "433")
            {
                NicknameInUse?.Invoke(this, null);
            }

            if (e.Message.Source != null &&
                e.Message.Source.Name == "NickServ" &&
                e.Message.Command == "NOTICE")
            {
                if (e.Message.Parameters[1] == "Password accepted - you are now recognized.")
                {
                    Task.Factory.StartNew(() =>
                    {
                        foreach (var channel in ChannelsToJoin)
                        {
                            Client.Channels.Join(channel);
                        }
                    });
                }
                else if (e.Message.Parameters[1] == "Password incorrect.")
                {
                    PasswordIncorrect?.Invoke(this, null);
                }
            }

            RawMessageReceived?.Invoke(this, $"{e.Message.Command} - {e.Message.Parameters.Where(x => x != null).Aggregate((a, b) => a + " " + b)}");
        }