~ruther/NosTale-Anonymizer

cbabc1998fb37720ac93a7e6d053c6b22d8aafce — František Boháček 2 years ago f56393b
feat: add keep header filter
2 files changed, 48 insertions(+), 4 deletions(-)

M src/Anonymizer/Filters/HeaderFilter.cs
M src/Anonymizer/Filters/HeaderFilterOptions.cs
M src/Anonymizer/Filters/HeaderFilter.cs => src/Anonymizer/Filters/HeaderFilter.cs +5 -0
@@ 32,6 32,11 @@ public class HeaderFilter : IFilter
        }

        var header = splitted[0];
        if (_options.KeepHeaders is not null)
        {
            return _options.KeepHeaders.Contains(header);
        }

        return !_options.RemoveHeaders.Contains(header);
    }
}
\ No newline at end of file

M src/Anonymizer/Filters/HeaderFilterOptions.cs => src/Anonymizer/Filters/HeaderFilterOptions.cs +43 -4
@@ 6,7 6,46 @@

namespace Anonymizer.Filters;

public record HeaderFilterOptions
(
    IReadOnlyList<string> RemoveHeaders
);
\ No newline at end of file
/// <summary>
/// Options for <see cref="HeaderFilter"/>.
/// </summary>
public class HeaderFilterOptions
{
    /// <summary>
    /// Gets or sets the headers to remove. <see cref="KeepHeaders"/> is prioritized.
    /// </summary>
    public IReadOnlyList<string> RemoveHeaders { get; set; } = new[]
    {
        "mv",
        "stat",
        "say",
        "spk",
        "bn",
        "inv",

        "qslot",
        "umi",
        "msgi2",
        "qnai2",

        "die",

        "throw",

        "bf",
        "bf_e",
        "dm",
        "finit",
        "finfo",
        "ptctl",
        "suctl", // figure out what it does
        "ct", // figure out what it does
    };

    /// <summary>
    /// Gets or sets the headers to keep. Takes priority before remove headers.
    /// </summary>
    public IReadOnlyList<string>? KeepHeaders { get; set; } = null;

    // rdlst, raid, raidmbf, raidbf, in, out, c_info, c_mode
}
\ No newline at end of file

Do not follow this link