| | | 1 | | namespace TeleFlow.Annotations; |
| | | 2 | | /// <summary> |
| | | 3 | | /// Routes a Telegram command message by matching a template and binding template values. |
| | | 4 | | /// </summary> |
| | | 5 | | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] |
| | | 6 | | public sealed class CommandTemplateAttribute : TeleFlowAttribute |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Creates a command template route. |
| | | 10 | | /// </summary> |
| | | 11 | | /// <param name="template">Command template such as <c>ticket {id:long?}</c>.</param> |
| | 82 | 12 | | public CommandTemplateAttribute(string template) |
| | | 13 | | { |
| | 82 | 14 | | ArgumentException.ThrowIfNullOrWhiteSpace(template); |
| | | 15 | | Template = template; |
| | 82 | 16 | | } |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Command template used for route matching and value binding. |
| | | 20 | | /// </summary> |
| | | 21 | | public string Template { get; } |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// Command prefixes accepted by this route. Defaults to <c>/</c>. |
| | | 25 | | /// </summary> |
| | 82 | 26 | | 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 literal template parts without case sensitivity. |
| | | 40 | | /// </summary> |
| | | 41 | | public bool IgnoreCase { get; set; } = true; |
| | | 42 | | } |