private FilterResult DoFilterString(string content) { if (this.StringPattern == null || this.StringPattern.Length == 0) { return(new FilterResult()); } var ret = new FilterResult(); if (!content.Contains(this.StringPattern)) { return(ret); } if (this.ReplaceTo != null) { ret.Content = content.Replace(this.StringPattern, this.ReplaceTo); } if (this.SendMessage != null) { ret.SendMessage = this.SendMessage; } return(ret); }
private FilterResult DoFilterRegex(string content) { if (this.RegexPattern == null) { return(new FilterResult()); } var ret = new FilterResult(); Match match = this.RegexPattern.Match(content); if (match == null || !match.Success) { return(ret); } if (this.ReplaceTo != null) { ret.Content = this.RegexPattern.Replace(content, this.ReplaceTo); } if (this.SendMessage != null) { ret.SendMessage = match.Result(this.SendMessage); } return(ret); }