Represents a raw irc line received over an irc connection.
Allows to analyze a raw irc line. The raw line is automatically broken down to it signle propertys as described in rfc 1459. They can be easily accessed by the given class propertys.
Наследование: IIrcObject
Пример #1
0
        public ChannelListLine(IrcLine baseLine)
            : base(baseLine)
        {
            if (baseLine.Numeric != 332)
                throw new ArgumentOutOfRangeException("baseLine", "CHANNELLIST_RPL 322 expected");
            if (Parameters.Length < 3)
                throw new ArgumentOutOfRangeException("baseLine", "Need a minimum of 3 parameters");

            if (!int.TryParse(Parameters[2], out userCount))
                throw new ArgumentOutOfRangeException("baseLine", "Invalid user count, integer expected");

            if (Parameters.Length > 3)
            {
                Regex ModeTopicRegex = new Regex(@"(?:\[\+([^ \]]*)] )?(.*)");
                Match m = ModeTopicRegex.Match(Parameters[3]);
                if (m.Success)
                {
                    modes = m.Groups[1].Value;
                    topic = m.Groups[2].Value;
                }
                else
                {
                    modes = "";
                    topic = "";
                }
            }
            else
            {
                modes = "";
                topic = "";
            }
        }
Пример #2
0
        public WhoLine(IrcLine baseLine)
            : base(baseLine)
        {
            if(baseLine.Numeric != 352)
                throw new ArgumentOutOfRangeException("baseLine", "RPL_WHOREPLY 352 expected");
            if(Parameters.Length < 8)
                throw new ArgumentOutOfRangeException("baseLine", "Need a minimum of 8 parameters");

            UserValue = new UserInfo(Parameters[5], Parameters[2], Parameters[3], Client);
            List<Mode> modes = new List<Mode>();
            int i = 1;

            IsAwayValue = Parameters[6][0] == 'G';
            IsOperValue = Parameters[6][i] == '*';

            if(IsOper)
                i++;

            for(; i < Parameters[6].Length; i++)
            {
                if(Client.Standard.UserPrefixFlags.ContainsKey(Parameters[6][i]))
                {
                    modes.Add(new Mode(Client.Standard.UserPrefixFlags[Parameters[6][i]], FlagArt.Set, User.NickName));
                }
            }

            ModesValue = modes.ToArray();

            RealNameValue = Parameters[7];

            if(!int.TryParse(RealNameValue.Substring(1, RealNameValue.IndexOf(" ")), out HopCountValue))
                throw new ArgumentOutOfRangeException("baseLine", "Invalid hop count, integer expected");

            RealNameValue = RealNameValue.Substring(RealNameValue.IndexOf(" ") + 1);
        }
Пример #3
0
        public PartReceivedEventArgs(IrcLine BaseLine)
            : base(BaseLine)
        {
            user = new UserInfo(BaseLine);
            channelName = BaseLine.Parameters[0];

            if (BaseLine.Parameters.Length > 1)
                partMessage = BaseLine.Parameters[1];
        }
Пример #4
0
        public QuitReceivedEventArgs(IrcLine BaseLine)
            : base(BaseLine)
        {
            user = new UserInfo(BaseLine);

            if (BaseLine.Parameters.Length > 0)
                quitMessage = BaseLine.Parameters[0];
            else
                quitMessage = "";
        }
Пример #5
0
        public ModeReceivedEventArgs(IrcLine BaseLine)
            : base(BaseLine)
        {
            long currentParam;
            FlagArt currentArt = FlagArt.Set;
            List<Mode> modes = new List<Mode>();
            List<FlagDefinition> flags = new List<FlagDefinition>();
            setter = BaseLine.Prefix;
            AimValue = BaseLine.Parameters[0];
            if (Client.Standard.IsAllowedChannel(AimValue))
            {
                flags.AddRange(Client.Standard.ChannelFlags);
                flags.AddRange(Client.Standard.UserPrefixFlags.Values);
                AimArtValue = ModeArt.Channel;
            }
            else
            {
                flags.AddRange(Client.Standard.UserFlags);
                AimArtValue = ModeArt.User;
            }
            currentParam = 2;

            foreach (char c in BaseLine.Parameters[1])
            {
                if (c == '+')
                    currentArt = FlagArt.Set;
                else if (c == '-')
                    currentArt = FlagArt.Unset;
                else
                {
                    foreach (FlagDefinition currentFlag in flags)
                    {
                        if (currentFlag.Char == c)
                        {
                            if (currentParam < BaseLine.Parameters.Length && currentFlag.IsParameter(currentArt, BaseLine.Parameters[currentParam]))
                            {
                                modes.Add(new Mode(currentFlag, currentArt, BaseLine.Parameters[currentParam]));
                                currentParam++;
                            }
                            else if (!currentFlag.NeedParameter(currentArt))
                            {
                                modes.Add(new Mode(currentFlag, currentArt));
                            }
                            break;
                        }
                    }
                }
            }
            ModesValue = modes.ToArray();
        }
Пример #6
0
        public UserInfo(IrcLine BaseLine)
        {
            baseLine = BaseLine;
            Match hostPieces;
            hostPieces = hostRegex.Match(BaseLine.Prefix);
            if (hostPieces.Success)
            {
                nickName = hostPieces.Groups[1].Value;
                ident = hostPieces.Groups[2].Value;
                host = hostPieces.Groups[3].Value;
                client = BaseLine.Client;
            }
            else
            {
                // TODO: trow Exception

            }
        }
        public PrivateMessageReceivedEventArgs(IrcLine baseLine)
            : base(baseLine)
        {
            sender = new UserInfo(baseLine);
            String line;
            line = Message;

            if (line[0] == '\x01' && line[line.Length - 1] == '\x01')
            {
                line = line.Substring(1, line.Length - 2);
                cTCPCommandString = line;
                int firstSpace = line.IndexOf(' ');

                if (firstSpace > 0)
                {
                    cTCPCommandString = line.Substring(0, firstSpace);
                    cTCPParameters = line.Substring(firstSpace + 1);
                }

                switch (cTCPCommandString)
                {
                    case "ACTION":
                        cTCPCommand = CTCPCommands.Action;
                        break;

                    case "VERSION":
                        cTCPCommand = CTCPCommands.Version;
                        break;

                    default:
                        cTCPCommand = CTCPCommands.Unkown;
                        break;
                }
            }
            else
            {
                cTCPCommand = CTCPCommands.None;
            }
        }
Пример #8
0
 public IrcEventArgs(IrcLine BaseLine)
 {
     handled = false;
     client = BaseLine.Client;
     baseLine = BaseLine;
 }
Пример #9
0
 public NumericReceivedEventArgs(IrcLine baseLine)
     : base(baseLine)
 {
 }
Пример #10
0
 public MotdEndEventArgs(IrcLine baseLine, IrcLine[] motdLines)
     : base(baseLine)
 {
     this.motdLines = motdLines;
 }
Пример #11
0
 public WhoBeginEventArgs(IrcLine baseLine)
     : base(baseLine)
 {
 }
Пример #12
0
 public LinksEndEventArgs(IrcLine baseLine, IrcLine[] linksLines)
     : base(baseLine)
 {
     this.linksLines = linksLines;
 }
Пример #13
0
 public MotdBeginEventArgs(IrcLine baseLine)
     : base(baseLine)
 {
 }
Пример #14
0
 public NoticeReceivedEventArgs(IrcLine baseLine)
     : base(baseLine)
 {
 }
Пример #15
0
 public WhoEndEventArgs(IrcLine baseLine, IrcLine[] WhoLines)
     : base(baseLine)
 {
     whoLines = WhoLines;
 }
Пример #16
0
 public UserInfo(UserInfo baseInfo)
 {
     baseLine = baseInfo.BaseLine;
     nickName = baseInfo.NickName;
     ident = baseInfo.Ident;
     host = baseInfo.Host;
     client = baseInfo.Client;
 }
Пример #17
0
 public ChannelListBeginEventArgs(IrcLine baseLine)
     : base(baseLine)
 {
 }
Пример #18
0
 public ChannelListEndEventArgs(IrcLine baseLine, IrcLine[] channellistLines)
     : base(baseLine)
 {
     channelListLines = channellistLines;
 }
Пример #19
0
 public BadNickEventArgs(IrcLine baseLine, bool inLogin)
     : base(baseLine)
 {
     isLogin = inLogin;
 }
Пример #20
0
 public NamesEndEventArgs(IrcLine baseLine, String[] names, String channelName)
     : base(baseLine)
 {
     this.names = names;
     ChannelNameValue = channelName;
 }
Пример #21
0
 public IrcLine(IrcLine source)
 {
     prefix = source.Prefix;
     command = source.Command;
     parameters = source.Parameters;
     client = source.Client;
     int.TryParse(Command, out numeric);
 }
Пример #22
0
 public LinksBeginEventArgs(IrcLine baseLine)
     : base(baseLine)
 {
 }
Пример #23
0
 public InfoEndEventArgs(IrcLine baseLine, IrcLine[] infoLines)
     : base(baseLine)
 {
     this.infoLines = infoLines;
 }