Убраны старые api
This commit is contained in:
@@ -14,66 +14,4 @@ public static class PageContextAdapterExtensions
|
||||
/// </summary>
|
||||
public static Task<string?> SendAsync(this PageContext ctx, SendRequest request, CancellationToken ct = default)
|
||||
=> ctx.Adapter.SendAsync(request, ct);
|
||||
|
||||
/// <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,
|
||||
object? adapterOptions = null,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
var bag = adapterOptions switch
|
||||
{
|
||||
null => null,
|
||||
AdapterOptionsBag b => b,
|
||||
_ => throw new ArgumentException("adapterOptions must be an AdapterOptionsBag or null. Use MessageBuilder extensions to set adapter options.", nameof(adapterOptions))
|
||||
};
|
||||
|
||||
return ctx.SendAsync(new SendRequest
|
||||
{
|
||||
ChatId = ctx.Update.Chat.Id,
|
||||
Text = text,
|
||||
TextFormat = format,
|
||||
Inline = inline,
|
||||
Reply = reply,
|
||||
MessageId = messageId,
|
||||
AdapterOptions = bag
|
||||
}, ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Удобная оболочка: отправить файл.
|
||||
/// </summary>
|
||||
public static Task<string?> SendFileAsync(this PageContext ctx,
|
||||
FileDescriptor file,
|
||||
string? caption = null,
|
||||
MessageFormat? captionFormat = null,
|
||||
IEnumerable<IEnumerable<InlineButton>>? inline = null,
|
||||
IEnumerable<IEnumerable<ReplyButton>>? reply = null,
|
||||
object? adapterOptions = null,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
var bag = adapterOptions switch
|
||||
{
|
||||
null => null,
|
||||
AdapterOptionsBag b => b,
|
||||
_ => throw new ArgumentException("adapterOptions must be an AdapterOptionsBag or null. Use MessageBuilder extensions to set adapter options.", nameof(adapterOptions))
|
||||
};
|
||||
|
||||
return ctx.SendAsync(new SendRequest
|
||||
{
|
||||
ChatId = ctx.Update.Chat.Id,
|
||||
File = file,
|
||||
Caption = caption,
|
||||
CaptionFormat = captionFormat,
|
||||
Inline = inline,
|
||||
Reply = reply,
|
||||
AdapterOptions = bag
|
||||
}, ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user