| | | 1 | | namespace TeleFlow.Annotations; |
| | | 2 | | /// <summary> |
| | | 3 | | /// Routes a Telegram text message by comparing it with a configured text value. |
| | | 4 | | /// </summary> |
| | | 5 | | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] |
| | | 6 | | public sealed class TextAttribute : TeleFlowAttribute |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Creates a text route. |
| | | 10 | | /// </summary> |
| | | 11 | | /// <param name="value">Text value to match.</param> |
| | | 12 | | /// <param name="mode">Text comparison mode.</param> |
| | | 13 | | /// <param name="ignoreCase">Whether text comparison ignores case.</param> |
| | 56 | 14 | | public TextAttribute( |
| | 56 | 15 | | string value, |
| | 56 | 16 | | TextMatchMode mode = TextMatchMode.Equals, |
| | 56 | 17 | | bool ignoreCase = true) |
| | | 18 | | { |
| | 56 | 19 | | ArgumentException.ThrowIfNullOrWhiteSpace(value); |
| | | 20 | | Value = value; |
| | | 21 | | Mode = mode; |
| | | 22 | | IgnoreCase = ignoreCase; |
| | 56 | 23 | | } |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// Text value used for route matching. |
| | | 27 | | /// </summary> |
| | | 28 | | public string Value { get; } |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// Text comparison mode. |
| | | 32 | | /// </summary> |
| | | 33 | | public TextMatchMode Mode { get; } |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// Indicates whether text comparison ignores case. |
| | | 37 | | /// </summary> |
| | | 38 | | public bool IgnoreCase { get; } |
| | | 39 | | } |