Files
BotPages/Demo/Pages/WelcomePage.cs
FrigaT e6e5459280
All checks were successful
CI / build-test (push) Successful in 30s
Доработано Demo
2025-12-05 13:33:25 +03:00

61 lines
1.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using BotPages.Core;
using BotPages.Core.Abstractions;
using BotPages.Core.Messaging;
namespace Demo.Pages;
/// <summary>
/// Стартовая страница демо‑бота.
/// Обычная страница с кнопками
/// </summary>
public sealed class WelcomePage : SingletonPage
{
public override async Task OnEnter(PageContext ctx, CancellationToken ct)
{
await ctx.ClearStorageAsync(ct);
await new MessageBuilder(ctx)
.Text("Добро пожаловать! 🚀")
.Reply(WelcomePageButtons.CreateRequest)
.Reply(WelcomePageButtons.Help)
.Reply(WelcomePageButtons.SendFile)
.SendAsync(ct);
}
public override Task OnText(PageContext ctx, string text, CancellationToken ct)
{
var button = ButtonExtensions.FromButtonLabel<WelcomePageButtons>(text);
switch (button)
{
case WelcomePageButtons.CreateRequest:
{
return ctx.Navigation.GoToAsync<TitlePage>(ctx, ct);
}
case WelcomePageButtons.Help:
{
return new MessageBuilder(ctx).Text("Здесь будет справка.", MessageFormat.Plain).SendAsync(ct);
}
case WelcomePageButtons.SendFile:
{
return ctx.Navigation.GoToAsync<FileSendPage>(ctx, ct);
}
}
return base.OnText(ctx, text, ct);
}
}
public enum WelcomePageButtons
{
[Button("Создать заявку")]
CreateRequest,
[Button("Помощь")]
Help,
[Button("Отправка файла")]
SendFile,
}