| | | 1 | | namespace 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)] |
| | | 6 | | public 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> |
| | 330 | 12 | | public CommandAttribute(string command) |
| | | 13 | | { |
| | 330 | 14 | | ArgumentException.ThrowIfNullOrWhiteSpace(command); |
| | | 15 | | Command = command; |
| | 330 | 16 | | } |
| | | 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> |
| | 330 | 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 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 | | } |