private static async Task PiracyCheckAsync(string line, LogParseState state) { if (await ContentFilter.FindTriggerAsync(FilterContext.Log, line).ConfigureAwait(false) is Piracystring match && match.Actions.HasFlag(FilterAction.RemoveContent)) { var m = match; if (line.Contains("not valid, removing from") || line.Contains("Invalid disc path registered")) { m = new Piracystring { Id = match.Id, Actions = match.Actions & ~FilterAction.IssueWarning, Context = match.Context, CustomMessage = match.CustomMessage, Disabled = match.Disabled, ExplainTerm = match.ExplainTerm, String = match.String, ValidatingRegex = match.ValidatingRegex, } } ; if (state.FilterTriggers.TryGetValue(m.Id, out var fh)) { var updatedActions = fh.filter.Actions | m.Actions; if (fh.context.Length > line.Length) { m.Actions = updatedActions; state.FilterTriggers[m.Id] = (m, line.ToUtf8()); } else { fh.filter.Actions = updatedActions; } if (updatedActions.HasFlag(FilterAction.IssueWarning)) { state.Error = LogParseState.ErrorCode.PiracyDetected; } } else { var utf8line = line.ToUtf8(); state.FilterTriggers[m.Id] = (m, utf8line); if (m.Actions.HasFlag(FilterAction.IssueWarning)) { state.Error = LogParseState.ErrorCode.PiracyDetected; } } } }