< Summary

Information
Class: TeleFlow.Annotations.CommandAttribute
Assembly: TeleFlow.Annotations
File(s): /_/src/TeleFlow.Annotations/Routing/CommandAttribute.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/CommandAttribute.cs

#LineLine coverage
 1namespace TeleFlow.Annotations;
 2/// <summary>
 3/// Routes a Telegram message to a handler when it contains the specified command.
 4/// </summary>
 5[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
 6public sealed class CommandAttribute : TeleFlowAttribute
 7{
 8    /// <summary>
 9    /// Creates a command route.
 10    /// </summary>
 11    /// <param name="command">Command name without the command prefix.</param>
 33012    public CommandAttribute(string command)
 13    {
 33014        ArgumentException.ThrowIfNullOrWhiteSpace(command);
 15        Command = command;
 33016    }
 17
 18    /// <summary>
 19    /// Command name without the command prefix.
 20    /// </summary>
 21    public string Command { get; }
 22
 23    /// <summary>
 24    /// Command prefixes accepted by this route. Defaults to <c>/</c>.
 25    /// </summary>
 33026    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 name.
 35    /// </summary>
 36    public bool AllowSpaceAfterPrefix { get; set; }
 37
 38    /// <summary>
 39    /// Matches the command name without case sensitivity.
 40    /// </summary>
 41    public bool IgnoreCase { get; set; } = true;
 42}

Methods/Properties

.ctor(System.String)