コード例 #1
0
        public void Append(ChatMessageLineResult lineParseResult)
        {
            this.RawMessage                 = this.RawMessage.Trim();
            lineParseResult.RawMessage      = lineParseResult.RawMessage.Trim();
            this.EnhancedMessage            = this.EnhancedMessage.Trim();
            lineParseResult.EnhancedMessage = lineParseResult.EnhancedMessage.Trim();

            this.RawMessage += " " + lineParseResult.RawMessage;
            var message     = lineParseResult.EnhancedMessage;
            var addedRivens = 0;

            for (int i = 0; i < message.Length;)
            {
                if (message[i] == '[' && i + 1 < message.Length && Char.IsDigit(message[i + 1]))
                {
                    var id    = Int32.Parse(message.Substring(i + 1, message.IndexOf(']', i + 1) - i - 1));
                    var newId = this.ClickPoints.Count + addedRivens;
                    message = message.Replace("[" + id + "]", "[" + newId + "]");
                    var p = lineParseResult.ClickPoints[addedRivens];
                    lineParseResult.ClickPoints[0] = new ClickPoint()
                    {
                        Index = this.EnhancedMessage.Length + i + 1, X = p.X, Y = p.Y
                    };
                    i = i + ("[" + newId + "]").ToString().Length;
                    addedRivens++;
                }
                else
                {
                    i++;
                }
            }
            this.ClickPoints.AddRange(lineParseResult.ClickPoints);
            this.EnhancedMessage += " " + message;
        }
コード例 #2
0
        private static ChatMessageModel MakeChatModel(LineParseResult.ChatMessageLineResult line)
        {
            var    badNameRegex = new Regex("[^-A-Za-z0-9._]");
            var    m            = line.RawMessage;
            string debugReason  = null;
            var    timestamp    = m.Substring(0, 7).Trim();
            var    username     = "******";

            try
            {
                username = m.Substring(8).Trim();
                if (username.IndexOf(":") > 0 && username.IndexOf(":") < username.IndexOf(" "))
                {
                    username = username.Substring(0, username.IndexOf(":"));
                }
                else
                {
                    username    = username.Substring(0, username.IndexOf(" "));
                    debugReason = "Bade name: " + username;
                }
                if (username.Contains(" ") || username.Contains(@"\/") || username.Contains("]") || username.Contains("[") || badNameRegex.Match(username).Success)
                {
                    debugReason = "Bade name: " + username;
                }
            }
            catch { debugReason = "Bade name: " + username; }
            var cm = new ChatMessageModel()
            {
                Raw             = m,
                Author          = username,
                Timestamp       = timestamp,
                SystemTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds()
            };

            if (debugReason != null)
            {
                cm.DEBUGREASON = debugReason;
            }
            cm.EnhancedMessage = line.EnhancedMessage;
            return(cm);
        }
コード例 #3
0
        private static ChatMessageModel MakeChatModel(LineParseResult.ChatMessageLineResult line)
        {
            var    badNameRegex = new Regex("[^-A-Za-z0-9._]");
            var    m            = line.RawMessage;
            string debugReason  = null;
            var    timestamp    = m.Substring(0, 7).Trim();
            var    username     = line.Username;

            try
            {
                if (username.Contains(" ") || username.Contains(@"\/") || username.Contains("]") || username.Contains("[") || badNameRegex.Match(username).Success)
                {
                    debugReason = "Bade name: " + username;
                }

                if (!Regex.Match(line.RawMessage, @"^(\[\d\d:\d\d\])\s*([-A-Za-z0-9._]+)\s*:?\s*(.+)").Success)
                {
                    debugReason = "Invalid username or timestamp!";
                }
            }
            catch { debugReason = "Bade name: " + username; }
            var cm = new ChatMessageModel()
            {
                Raw             = m,
                Author          = username,
                Timestamp       = timestamp,
                SystemTimestamp = DateTimeOffset.UtcNow
            };

            if (debugReason != null)
            {
                cm.DEBUGREASON = debugReason;
            }
            cm.EnhancedMessage = line.EnhancedMessage;
            return(cm);
        }