Exemplo n.º 1
0
        static int GetUserID(string nick, int channelID)
        {
            nick = nick.ToLowerInvariant();

            int userID;

            lock (channelSync)
            {
                userID = Channels[channelID].Users.FindIndex(u => u.Nick == nick);

                if (userID == -1)
                {
                    User user = new User();
                    user.Nick = nick;
                    Channels[channelID].Users.Add(user);
                    userID = Channels[channelID].Users.IndexOf(user);

                    MBEvents.OnUserListModified();
                }
            }

            return userID;
        }
Exemplo n.º 2
0
        /// <summary>
        /// NAMES reply
        /// </summary>
        /// <param name="message"></param>
        public static void Parse353(BotMessage message)
        {
            int channelID = GetChannelID(message.MessageList[4]);

            string nameString = message.RawMessage.Substring(message.RawMessage.LastIndexOf(':') + 1);
            List<string> names = nameString.Split(' ').ToList();

            foreach (string name in names)
            {
                if (name == "") continue;

                string nick = "", symbols = "";

                Match match = Regex.Match(name, @"([~@%&+]+)?(.+)");
                if (match.Groups.Count > 2)
                {
                    symbols = match.Groups[1].Value;
                    nick = match.Groups[2].Value.ToLowerInvariant();
                }
                else
                {
                    nick = match.Groups[1].Value.ToLowerInvariant();
                }

                lock (channelSync)
                {
                    if (Channels[channelID].Users.FindIndex(u => u.Nick == nick) == -1)
                    {
                        User user = new User();
                        user.Nick = nick;
                        user.Symbols = symbols;

                        Channels[channelID].Users.Add(user);
                    }
                }
            }
            MBEvents.OnUserListModified();
        }