37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using BotPages.Core;
|
|
using BotPages.Core.Abstractions;
|
|
using BotPages.Core.Messaging;
|
|
|
|
namespace Demo.Pages;
|
|
|
|
/// <summary>
|
|
/// Страница загрузки файлов.
|
|
/// </summary>
|
|
public sealed class FilesPage : Page
|
|
{
|
|
public override Task OnEnter(PageContext ctx, CancellationToken ct)
|
|
=> new MessageBuilder(ctx)
|
|
.Text("Пришлите файлы для заявки 📎", MessageFormat.Markdown)
|
|
.Reply("Пропустить")
|
|
.SendAsync(ct);
|
|
|
|
public override async Task OnFile(PageContext ctx, List<FileDescriptor> files, CancellationToken ct)
|
|
{
|
|
foreach (var file in files)
|
|
{
|
|
await ctx.SendFileAsync(file, $"Файл '{file.Name}' получен и отправлен обратно.", ct);
|
|
}
|
|
|
|
await new MessageBuilder(ctx)
|
|
.Text($"Получено файлов: {files.Count}", MessageFormat.Plain)
|
|
.Inline("Далее", "next")
|
|
.SendAsync(ct);
|
|
}
|
|
|
|
public override Task OnButton(PageContext ctx, string payload, CancellationToken ct)
|
|
=> ctx.Navigation.GoToAsync<ConfirmPage>(ctx, ct);
|
|
|
|
public override Task OnText(PageContext ctx, string text, CancellationToken ct)
|
|
=> ctx.Navigation.GoToAsync<ConfirmPage>(ctx, ct);
|
|
}
|