< Summary

Information
Class: TeleFlow.Annotations.FromUserAttribute
Assembly: TeleFlow.Annotations
File(s): /_/src/TeleFlow.Annotations/Filters/FromUserAttribute.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/FromUserAttribute.cs

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

Methods/Properties

.ctor(System.Int64[])