< Summary

Information
Class: TeleFlow.Annotations.SenderChatTypeAttribute
Assembly: TeleFlow.Annotations
File(s): /_/src/TeleFlow.Annotations/Filters/SenderChatTypeAttribute.cs
Line coverage
83%
Covered lines: 5
Uncovered lines: 1
Coverable lines: 6
Total lines: 29
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/SenderChatTypeAttribute.cs

#LineLine coverage
 1namespace TeleFlow.Annotations;
 2
 3/// <summary>
 4/// Restricts a message or command handler to messages sent on behalf of specific Telegram chat types.
 5/// </summary>
 6[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
 7public sealed class SenderChatTypeAttribute : TeleFlowAttribute
 8{
 9    /// <summary>
 10    /// Creates a sender chat type filter.
 11    /// </summary>
 12    /// <param name="chatTypes">Telegram chat types allowed for <c>message.sender_chat</c>.</param>
 1613    public SenderChatTypeAttribute(params TelegramChatType[] chatTypes)
 14    {
 1615        ArgumentNullException.ThrowIfNull(chatTypes);
 16
 1617        if (chatTypes.Length == 0)
 18        {
 019            throw new ArgumentException("At least one Telegram sender chat type must be specified.", nameof(chatTypes));
 20        }
 21
 1622        ChatTypes = chatTypes.ToArray();
 1623    }
 24
 25    /// <summary>
 26    /// Telegram chat types allowed for <c>message.sender_chat</c>.
 27    /// </summary>
 28    public IReadOnlyList<TelegramChatType> ChatTypes { get; }
 29}