Beispiel #1
0
        private void RcvMode(IrcMessage message)
        {
            string channel = message.Parameters[0];
            string userid = "", userhost = "";
            string[] split = message.Prefix.Split(USERHOST_SIGNS);

            string nick = split[0];
            if (split.Length > 1)
                userid = split[1];
            if (split.Length > 2)
                userhost = split[2];

            int number_of_targets = message.Parameters.Length - 2;
            if (number_of_targets == 0)
            {
                string modes = message.Parameters[1];
                List<ModeChange> changes = new List<ModeChange>(modes.Length - 1);
                bool adding = false;
                foreach (char mode in modes)
                {
                    switch (mode)
                    {
                        case '+': adding = true;
                            break;
                        case '-': adding = false;
                            break;
                        default:
                            changes.Add(new ModeChange()
                            {
                                IsAdded = adding,
                                IsGlobalMode = true,
                                Mode = mode,
                                Name = message.Parameters[0]
                            });
                            break;
                    }
                }

                if(this.OnMode != null)
                    OnMode(this, new IrcClientOnModeEventArgs(userid, nick, userhost, channel, changes.ToArray()));
            }
            else
            {
                ModeChange[] changes = new ModeChange[number_of_targets];
                string modes = message.Parameters[1];
                int modeslength = modes.Length;
                bool adding = false;
                int modecursor = 0;
                foreach(char mode in modes)
                {
                    switch (mode)
                    {
                        case '+': adding = true;
                            break;
                        case '-': adding = false;
                            break;
                        default:
                            changes[modecursor].IsAdded = adding;
                            changes[modecursor].Mode = mode;
                            changes[modecursor].Name = message.Parameters[2 + modecursor];
                            changes[modecursor].IsGlobalMode = false;
                            modecursor++;
                            break;
                    }
                }
                if(this.OnMode != null)
                    OnMode(this, new IrcClientOnModeEventArgs(userid, nick, userhost, channel, changes));
            }
        }
Beispiel #2
0
 public IrcClientOnModeEventArgs(string userid, string name, string userhost, string channel, ModeChange[] modeChanges)
 {
     UserID = userid;
     Name = name;
     Userhost = userhost;
     Channel = channel;
     ModeChanges = modeChanges;
 }