< Summary

Information
Class: TeleFlow.Telegram.TelegramClientEphemeralMessageExtensions
Assembly: TeleFlow.Telegram.Client
File(s): /_/src/TeleFlow.Telegram.Client/TelegramClientEphemeralMessageExtensions.cs
Line coverage
100%
Covered lines: 17
Uncovered lines: 0
Coverable lines: 17
Total lines: 45
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            receiverUserId: target.ReceiverUserId,
 433            callbackQueryId: callbackQueryId,
 434            replyMarkup: replyMarkup is null ? null : ReplyMarkup.From(replyMarkup),
 435            cancellationToken: cancellationToken).ConfigureAwait(false);
 36
 437        if (message.EphemeralMessageId is not long ephemeralMessageId)
 38        {
 139            throw new InvalidOperationException(
 140                "Telegram returned an ephemeral message without an ephemeral_message_id.");
 41        }
 42
 343        return new EphemeralMessageReference(bot, target, ephemeralMessageId, message);
 344    }
 45}

Methods/Properties

SendEphemeralMessageAsync()