コード例 #1
0
        public TwitchChatRewardParser(TwitchInputLine command)
        {
            BadgesText = TwitchChatRegex.RewardRegex.Match(command.Message).Groups[1].Value;
            Id         = TwitchChatRegex.RewardRegex.Match(command.Message).Groups[2].Value;
            string displayName = TwitchChatRegex.RewardRegex.Match(command.Message).Groups[3].Value;
            string idUser      = TwitchChatRegex.RewardRegex.Match(command.Message).Groups[4].Value;
            string username    = TwitchChatRegex.RewardRegex.Match(command.Message).Groups[5].Value;

            Sent   = TwitchChatRegex.RewardRegex.Match(command.Message).Groups[6].Value;
            Badges = TwitchChatRegex.BuildBadges(BadgesText);
            User   = TwitchUserManager.AddUser(username);
            User.SetData(idUser, displayName, Badges);
        }
コード例 #2
0
        public TwitchChatMessageParser(TwitchInputLine command)
        {
            Bits = 0;

            Id = TwitchChatRegex.IdMessageRegex.Match(command.Message).Groups[1].Value;
            string badgesText  = TwitchChatRegex.MessageRegex.Match(command.Message).Groups[1].Value;
            string displayName = TwitchChatRegex.MessageRegex.Match(command.Message).Groups[2].Value;
            string idUser      = TwitchChatRegex.MessageRegex.Match(command.Message).Groups[3].Value;
            string username    = TwitchChatRegex.MessageRegex.Match(command.Message).Groups[4].Value;

            Sent = TwitchChatRegex.MessageRegex.Match(command.Message).Groups[5].Value;

            Badges = TwitchChatRegex.BuildBadges(badgesText);
            User   = TwitchUserManager.AddUser(username);
            User.SetData(idUser, displayName, Badges);

            if (Sent.Length == 0)
            {
                return;
            }

            MatchCollection matches = TwitchChatRegex.CheerRegex.Matches(Sent);

            foreach (Match match in matches)
            {
                if (match.Groups.Count != 2)
                {
                    continue;                          // First group is 'cheerXX', second group is XX.
                }
                string value = match.Groups[1].Value;
                if (!int.TryParse(value, out int bitsAmount))
                {
                    continue;
                }
                Bits += bitsAmount;
            }
        }