40 lines
1.4 KiB
C#
40 lines
1.4 KiB
C#
using BotPages.Core;
|
|
|
|
namespace Demo.Pages
|
|
{
|
|
public sealed class FilesPage : Page
|
|
{
|
|
public static string Id => nameof(FilesPage);
|
|
|
|
public override Task<PageResult> EnterAsync(UpdateContext ctx, CancellationToken ct)
|
|
{
|
|
var actions = new[]
|
|
{
|
|
new PageAction { Label = "⬅️ Назад", Value = "back", Placement = ActionPlacement.Reply, Row = 0 }
|
|
};
|
|
|
|
return Task.FromResult(
|
|
PageResultBuilder.Empty()
|
|
.WithText("📂 Здесь можно загрузить или отправить файл.")
|
|
.WithKeyboard(actions)
|
|
.Build()
|
|
);
|
|
}
|
|
|
|
public override async Task<PageResult> HandleAsync(UpdateContext ctx, CancellationToken ct)
|
|
{
|
|
if (ctx.Text == "⬅️ Назад")
|
|
return PageResultBuilder.Empty().WithNavigate(nameof(MainPage)).Build();
|
|
|
|
if (ctx.IncomingFiles?.Count > 0)
|
|
{
|
|
await ctx.Client.SendFilesAsync(ctx.Chat.Id, ctx.IncomingFiles, ct);
|
|
return PageResultBuilder.Empty().WithText("Файл получен и отправлен обратно.").Build();
|
|
}
|
|
|
|
return PageResultBuilder.Empty().WithText("Пришлите файл или нажмите 'Назад'.").Build();
|
|
}
|
|
}
|
|
|
|
}
|