41 lines
1.4 KiB
C#
41 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<string?> SendTextAsync(this PageContext ctx,
|
||
string text,
|
||
MessageFormat format = MessageFormat.Plain,
|
||
IEnumerable<IEnumerable<InlineButton>>? inline = null,
|
||
IEnumerable<IEnumerable<ReplyButton>>? reply = null,
|
||
string? messageId = null,
|
||
CancellationToken ct = default)
|
||
=> ctx.Adapter.SendTextAsync(ctx.Update.Chat.Id, text, format, inline, reply, messageId, ct);
|
||
|
||
/// <summary>
|
||
/// Отправить файл.
|
||
/// </summary>
|
||
public static Task SendFileAsync(this PageContext ctx,
|
||
FileDescriptor file,
|
||
string? caption = null,
|
||
MessageFormat? captionFormat = null,
|
||
IEnumerable<IEnumerable<InlineButton>>? inline = null,
|
||
IEnumerable<IEnumerable<ReplyButton>>? reply = null,
|
||
CancellationToken ct = default
|
||
)
|
||
=> ctx.Adapter.SendFileAsync(chatId: ctx.Update.Chat.Id,
|
||
file: file,
|
||
caption: caption,
|
||
captionFormat: captionFormat,
|
||
inline: inline,
|
||
reply: reply,
|
||
ct: ct);
|
||
} |