< Summary

Information
Class: TeleFlow.Annotations.FromBotAttribute
Assembly: TeleFlow.Annotations
File(s): /_/src/TeleFlow.Annotations/Filters/FromBotAttribute.cs
Line coverage
83%
Covered lines: 5
Uncovered lines: 1
Coverable lines: 6
Total lines: 28
Line coverage: 83.3%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)50%2283.33%

File(s)

/_/src/TeleFlow.Annotations/Filters/FromBotAttribute.cs

#LineLine coverage
 1namespace TeleFlow.Annotations;
 2/// <summary>
 3/// Restricts a handler or handler class to Telegram bots, optionally limited by bot user id.
 4/// </summary>
 5[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
 6public sealed class FromBotAttribute : TeleFlowAttribute
 7{
 8    /// <summary>
 9    /// Creates a sender bot filter.
 10    /// </summary>
 11    /// <param name="botIds">Optional Telegram bot user ids allowed to match.</param>
 1412    public FromBotAttribute(params long[] botIds)
 13    {
 1414        ArgumentNullException.ThrowIfNull(botIds);
 15
 1916        if (botIds.Any(static botId => botId <= 0))
 17        {
 018            throw new ArgumentException("Telegram bot ids must be positive.", nameof(botIds));
 19        }
 20
 1421        BotIds = botIds.ToArray();
 1422    }
 23
 24    /// <summary>
 25    /// Optional Telegram bot user ids allowed to match. An empty collection allows any bot.
 26    /// </summary>
 27    public IReadOnlyList<long> BotIds { get; }
 28}

Methods/Properties

.ctor(System.Int64[])