31 lines
1.4 KiB
C#
31 lines
1.4 KiB
C#
using BotPages.Core.Abstractions;
|
||
using BotPages.Core.Messaging;
|
||
|
||
namespace BotPages.Core;
|
||
|
||
/// <summary>
|
||
/// Расширения <see cref="PageContext"/> для работы с <see cref="IMessengerAdapter"/>
|
||
/// </summary>
|
||
public static class PageContextAdapterExtensions
|
||
{
|
||
/// <summary>
|
||
/// Отправить текстовое сообщение.
|
||
/// </summary>
|
||
public static Task SendTextAsync(this PageContext ctx, string text, MessageFormat format = MessageFormat.Plain,
|
||
IEnumerable<IEnumerable<InlineButton>>? inline = null,
|
||
IEnumerable<IEnumerable<ReplyButton>>? reply = null,
|
||
CancellationToken ct = default)
|
||
=> ctx.Adapter.SendTextAsync(ctx.Update.Chat.Id, text, format, inline, reply, ct);
|
||
|
||
/// <summary>
|
||
/// Отправить файл.
|
||
/// </summary>
|
||
public static Task SendFileAsync(this PageContext ctx, FileDescriptor file, string? caption = null, MessageFormat? captionFormat = null, CancellationToken ct = default)
|
||
=> ctx.Adapter.SendFileAsync(ctx.Update.Chat.Id, file, caption, captionFormat, ct);
|
||
|
||
/// <summary>
|
||
/// Отправить файл.
|
||
/// </summary>
|
||
public static Task SendFileAsync(this PageContext ctx, FileDescriptor file, string? caption = null, CancellationToken ct = default)
|
||
=> ctx.Adapter.SendFileAsync(ctx.Update.Chat.Id, file, caption, null, ct);
|
||
} |