Files
BotPages/Demo/Pages/WelcomePage.cs
FrigaT edc718b1f9
All checks were successful
CI / build-test (push) Successful in 31s
Release / pack-and-publish (release) Successful in 35s
Доработан обработчик команд. Добавлена публикация команд
2025-12-07 10:09:59 +03:00

63 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;
using BotPages.Core.Routing;
namespace Demo.Pages;
/// <summary>
/// Стартовая страница демо‑бота.
/// Обычная страница с кнопками
/// </summary>
[Route("Welcome")]
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,
}