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.
Inheritance: IIrcObject
Exemplo n.º 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 = "";
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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];
        }
Exemplo n.º 4
0
        public QuitReceivedEventArgs(IrcLine BaseLine)
            : base(BaseLine)
        {
            user = new UserInfo(BaseLine);

            if (BaseLine.Parameters.Length > 0)
                quitMessage = BaseLine.Parameters[0];
            else
                quitMessage = "";
        }
Exemplo n.º 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();
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 8
0
 public IrcEventArgs(IrcLine BaseLine)
 {
     handled = false;
     client = BaseLine.Client;
     baseLine = BaseLine;
 }
Exemplo n.º 9
0
 public NumericReceivedEventArgs(IrcLine baseLine)
     : base(baseLine)
 {
 }
Exemplo n.º 10
0
 public MotdEndEventArgs(IrcLine baseLine, IrcLine[] motdLines)
     : base(baseLine)
 {
     this.motdLines = motdLines;
 }
Exemplo n.º 11
0
 public WhoBeginEventArgs(IrcLine baseLine)
     : base(baseLine)
 {
 }
Exemplo n.º 12
0
 public LinksEndEventArgs(IrcLine baseLine, IrcLine[] linksLines)
     : base(baseLine)
 {
     this.linksLines = linksLines;
 }
Exemplo n.º 13
0
 public MotdBeginEventArgs(IrcLine baseLine)
     : base(baseLine)
 {
 }
Exemplo n.º 14
0
 public NoticeReceivedEventArgs(IrcLine baseLine)
     : base(baseLine)
 {
 }
Exemplo n.º 15
0
 public WhoEndEventArgs(IrcLine baseLine, IrcLine[] WhoLines)
     : base(baseLine)
 {
     whoLines = WhoLines;
 }
Exemplo n.º 16
0
 public UserInfo(UserInfo baseInfo)
 {
     baseLine = baseInfo.BaseLine;
     nickName = baseInfo.NickName;
     ident = baseInfo.Ident;
     host = baseInfo.Host;
     client = baseInfo.Client;
 }
Exemplo n.º 17
0
 public ChannelListBeginEventArgs(IrcLine baseLine)
     : base(baseLine)
 {
 }
Exemplo n.º 18
0
 public ChannelListEndEventArgs(IrcLine baseLine, IrcLine[] channellistLines)
     : base(baseLine)
 {
     channelListLines = channellistLines;
 }
Exemplo n.º 19
0
 public BadNickEventArgs(IrcLine baseLine, bool inLogin)
     : base(baseLine)
 {
     isLogin = inLogin;
 }
Exemplo n.º 20
0
 public NamesEndEventArgs(IrcLine baseLine, String[] names, String channelName)
     : base(baseLine)
 {
     this.names = names;
     ChannelNameValue = channelName;
 }
Exemplo n.º 21
0
 public IrcLine(IrcLine source)
 {
     prefix = source.Prefix;
     command = source.Command;
     parameters = source.Parameters;
     client = source.Client;
     int.TryParse(Command, out numeric);
 }
Exemplo n.º 22
0
 public LinksBeginEventArgs(IrcLine baseLine)
     : base(baseLine)
 {
 }
Exemplo n.º 23
0
 public InfoEndEventArgs(IrcLine baseLine, IrcLine[] infoLines)
     : base(baseLine)
 {
     this.infoLines = infoLines;
 }