< Summary

Information
Class: TeleFlow.Telegram.TelegramClientEphemeralMessageExtensions
Assembly: TeleFlow.Telegram.Client
File(s): /_/src/TeleFlow.Telegram.Client/TelegramClientEphemeralMessageExtensions.cs
Line coverage
100%
Covered lines: 20
Uncovered lines: 0
Coverable lines: 20
Total lines: 48
Line coverage: 100%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
SendEphemeralMessageAsync()83.33%66100%

File(s)

/_/src/TeleFlow.Telegram.Client/TelegramClientEphemeralMessageExtensions.cs

#LineLine coverage
 1using TeleFlow.Telegram.Schema.Abstractions;
 2using TeleFlow.Telegram.Schema.Types;
 3
 4namespace TeleFlow.Telegram;
 5
 6/// <summary>
 7/// Provides explicit client-level conveniences for sending Telegram ephemeral text messages.
 8/// Framework context helpers use this surface after deriving an ephemeral target from an incoming update.
 9/// </summary>
 10public static class TelegramClientEphemeralMessageExtensions
 11{
 12    public static async Task<EphemeralMessageReference> SendEphemeralMessageAsync(
 13        this ITelegramClient bot,
 14        EphemeralMessageTarget target,
 15        string text,
 16        InlineKeyboardMarkup? replyMarkup = null,
 17        string? callbackQueryId = null,
 18        CancellationToken cancellationToken = default)
 19    {
 520        ArgumentNullException.ThrowIfNull(bot);
 521        ArgumentNullException.ThrowIfNull(target);
 522        ArgumentException.ThrowIfNullOrWhiteSpace(text);
 23
 524        if (callbackQueryId is not null)
 25        {
 226            ArgumentException.ThrowIfNullOrWhiteSpace(callbackQueryId);
 27        }
 28
 429        var message = await bot.SendMessageAsync(
 430            target.ChatId,
 431            text,
 432            ephemeralMessageParameters: new EphemeralMessageParameters
 433            {
 434                ReceiverUserId = target.ReceiverUserId,
 435                CallbackQueryId = callbackQueryId
 436            },
 437            replyMarkup: replyMarkup is null ? null : ReplyMarkup.From(replyMarkup),
 438            cancellationToken: cancellationToken).ConfigureAwait(false);
 39
 440        if (message.EphemeralMessageId is not long ephemeralMessageId)
 41        {
 142            throw new InvalidOperationException(
 143                "Telegram returned an ephemeral message without an ephemeral_message_id.");
 44        }
 45
 346        return new EphemeralMessageReference(bot, target, ephemeralMessageId, message);
 347    }
 48}

Methods/Properties

SendEphemeralMessageAsync()