< Summary

Information
Class: TeleFlow.Annotations.CommandRegexAttribute
Assembly: TeleFlow.Annotations
File(s): /_/src/TeleFlow.Annotations/Routing/CommandRegexAttribute.cs
Line coverage
100%
Covered lines: 4
Uncovered lines: 0
Coverable lines: 4
Total lines: 42
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%

File(s)

/_/src/TeleFlow.Annotations/Routing/CommandRegexAttribute.cs

#LineLine coverage
 1namespace TeleFlow.Annotations;
 2/// <summary>
 3/// Routes a Telegram command message by matching the command body with a regular expression.
 4/// </summary>
 5[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
 6public sealed class CommandRegexAttribute : TeleFlowAttribute
 7{
 8    /// <summary>
 9    /// Creates a command regex route.
 10    /// </summary>
 11    /// <param name="pattern">Regular expression pattern applied to the command body.</param>
 1812    public CommandRegexAttribute(string pattern)
 13    {
 1814        ArgumentException.ThrowIfNullOrWhiteSpace(pattern);
 15        Pattern = pattern;
 1816    }
 17
 18    /// <summary>
 19    /// Regular expression pattern applied to the command body.
 20    /// </summary>
 21    public string Pattern { get; }
 22
 23    /// <summary>
 24    /// Command prefixes accepted by this route. Defaults to <c>/</c>.
 25    /// </summary>
 1826    public string[] Prefixes { get; set; } = ["/"];
 27
 28    /// <summary>
 29    /// Defines whether the command prefix is required, optional, or disabled for this route.
 30    /// </summary>
 31    public CommandPrefixMode PrefixMode { get; set; } = CommandPrefixMode.Required;
 32
 33    /// <summary>
 34    /// Allows whitespace between the prefix and command body.
 35    /// </summary>
 36    public bool AllowSpaceAfterPrefix { get; set; }
 37
 38    /// <summary>
 39    /// Matches the command body without case sensitivity.
 40    /// </summary>
 41    public bool IgnoreCase { get; set; } = true;
 42}

Methods/Properties

.ctor(System.String)