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
파일: WhoLine.cs 프로젝트: hapm/IrcShark
        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
파일: UserInfo.cs 프로젝트: hapm/IrcShark
        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
파일: UserInfo.cs 프로젝트: hapm/IrcShark
 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
파일: IrcLine.cs 프로젝트: hapm/IrcShark
 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;
 }