diff --git a/Telegrator/Annotations/CommandArgumentAttributes.cs b/Telegrator/Annotations/CommandArgumentAttributes.cs
index cff75c0..6c1ec1a 100644
--- a/Telegrator/Annotations/CommandArgumentAttributes.cs
+++ b/Telegrator/Annotations/CommandArgumentAttributes.cs
@@ -3,6 +3,10 @@ using Telegrator.Filters;
namespace Telegrator.Annotations
{
+ ///
+ /// Attribute for filtering messages where a command has arguments count >= .
+ ///
+ ///
public class ArgumentCountAttribute(int count)
: MessageFilterAttribute(new ArgumentCountFilter(count))
{ }
@@ -52,7 +56,6 @@ namespace Telegrator.Annotations
///
/// The regular expression pattern to match against the command argument.
/// The regex options to use for the pattern matching.
- /// The timeout for the regex match operation.
/// The index of the argument to check (0-based).
public class ArgumentRegexAttribute(string pattern, RegexOptions options = RegexOptions.None, int index = 0)
: MessageFilterAttribute(new ArgumentRegexFilter(pattern, options, index: index))
diff --git a/Telegrator/Filters/CommandArgumentFilter.cs b/Telegrator/Filters/CommandArgumentFilter.cs
index c41b4f8..10bbe03 100644
--- a/Telegrator/Filters/CommandArgumentFilter.cs
+++ b/Telegrator/Filters/CommandArgumentFilter.cs
@@ -42,10 +42,15 @@ namespace Telegrator.Filters
protected abstract bool CanPassNext(FilterExecutionContext context);
}
+ ///
+ /// Filter that checks if a command has arguments count >= .
+ ///
+ ///
public class ArgumentCountFilter(int count) : Filter
{
private readonly int Count = count;
+ ///
public override bool CanPass(FilterExecutionContext context)
{
CommandHandlerAttribute attr = context.CompletedFilters.Get(0);
diff --git a/Telegrator/Handlers/Components/FiltersFallbackReport.cs b/Telegrator/Handlers/Components/FiltersFallbackReport.cs
index fb1b9f7..9a0ab6b 100644
--- a/Telegrator/Handlers/Components/FiltersFallbackReport.cs
+++ b/Telegrator/Handlers/Components/FiltersFallbackReport.cs
@@ -38,6 +38,12 @@ namespace Telegrator.Handlers.Components
///
public List UpdateFilters { get; } = [];
+ ///
+ /// Checks if the failure is due to a specific filter.
+ ///
+ ///
+ ///
+ ///
public bool Only(string name, int index = 0)
{
FilterFallbackInfo? info = UpdateFilters.SingleSafe(info => info.Failed);
@@ -48,6 +54,11 @@ namespace Telegrator.Handlers.Components
return ReferenceEquals(target, info);
}
+ ///
+ /// Checks if the failure is due to a specific filter.
+ ///
+ ///
+ ///
public bool Only(string[] names)
{
return UpdateFilters
@@ -56,6 +67,12 @@ namespace Telegrator.Handlers.Components
.SequenceEqual(names);
}
+ ///
+ /// Checks if the failure is due to all filters except one.
+ ///
+ ///
+ ///
+ ///
public bool Except(string name, int index = 0)
{
FilterFallbackInfo? info = UpdateFilters.SingleSafe(info => !info.Failed);
@@ -66,6 +83,11 @@ namespace Telegrator.Handlers.Components
return ReferenceEquals(target, info);
}
+ ///
+ /// Checks if the failure is due to all filters except one.
+ ///
+ ///
+ ///
public bool Except(string[] names)
{
return UpdateFilters
@@ -74,6 +96,12 @@ namespace Telegrator.Handlers.Components
.SequenceEqual(names);
}
+ ///
+ /// Checks if the failure is due to aall attribute type, excluding one.
+ ///
+ /// The attribute type to check for.
+ /// The index of the filter to check (default: 0).
+ /// True if the failure is exclusively due to the specified attribute type; otherwise, false.
public bool ExceptAttribute(int index = 0) where T : UpdateFilterAttributeBase
=> Except(nameof(T), index);
diff --git a/Telegrator/TypesExtensions.cs b/Telegrator/TypesExtensions.cs
index 6d2c885..398da21 100644
--- a/Telegrator/TypesExtensions.cs
+++ b/Telegrator/TypesExtensions.cs
@@ -1009,6 +1009,13 @@ namespace Telegrator
}
}
+ ///
+ /// Return index of first element that satisfies the condition
+ ///
+ ///
+ ///
+ ///
+ ///
public static int IndexOf(this IEnumerable source, Func predicate)
{
int index = 0;
@@ -1023,12 +1030,34 @@ namespace Telegrator
return -1;
}
+ ///
+ /// Returns an enumerable that repeats the item multiple times.
+ ///
+ ///
+ ///
+ ///
+ ///
public static IEnumerable Repeat(this T item, int times)
=> Enumerable.Range(0, times).Select(_ => item);
+ ///
+ /// Returns the only element of a sequence, or a default value if the sequence is empty.
+ /// This method returns default if there is more than one element in the sequence.
+ ///
+ ///
+ ///
+ ///
public static T? SingleSafe(this IEnumerable source)
=> source.Count() == 1 ? source.ElementAt(0) : default;
+ ///
+ /// Returns the only element of a sequence that satisfies a specified condition or a default value if no such element exists.
+ /// This method return default if more than one element satisfies the condition.
+ ///
+ ///
+ ///
+ ///
+ ///
public static T? SingleSafe(this IEnumerable source, Func predicate)
{
source = source.Where(predicate);
@@ -1198,6 +1227,11 @@ namespace Telegrator
}
}
+ ///
+ /// Return new string with first found letter set to upper case
+ ///
+ ///
+ ///
public static string FirstLetterToUpper(this string target)
{
char[] chars = target.ToCharArray();
@@ -1206,6 +1240,11 @@ namespace Telegrator
return new string(chars);
}
+ ///
+ /// Return new string with first found letter set to lower case
+ ///
+ ///
+ ///
public static string FirstLetterToLower(this string target)
{
char[] chars = target.ToCharArray();