52 lines
1.8 KiB
C#
52 lines
1.8 KiB
C#
using BotPages.Core;
|
||
|
||
namespace Demo.Pages
|
||
{
|
||
public sealed class MainPage : Page
|
||
{
|
||
public override string Id => nameof(MainPage);
|
||
|
||
public override Task<PageResult> EnterAsync(UpdateContext ctx, CancellationToken ct)
|
||
{
|
||
var actions = new[]
|
||
{
|
||
new PageAction(MainPageButtons.Inline) { Placement = ActionPlacement.Reply, Row = 0 },
|
||
new PageAction(MainPageButtons.Reply) { Placement = ActionPlacement.Reply, Row = 1 },
|
||
new PageAction(MainPageButtons.Files) { Placement = ActionPlacement.Reply, Row = 2 },
|
||
};
|
||
|
||
return Task.FromResult(
|
||
PageResultBuilder.Empty()
|
||
.WithText("🏠 Главная страница.\nВыберите куда перейти:")
|
||
.WithKeyboard(actions)
|
||
.Build()
|
||
);
|
||
}
|
||
|
||
public override Task<PageResult> HandleAsync(UpdateContext ctx, CancellationToken ct)
|
||
{
|
||
var button = ActionExtensions.FromActionLabel<MainPageButtons>(ctx.Text);
|
||
|
||
return button switch
|
||
{
|
||
MainPageButtons.Inline => Task.FromResult(PageResultBuilder.Empty().WithNavigate(nameof(InlinePage)).Build()),
|
||
MainPageButtons.Reply => Task.FromResult(PageResultBuilder.Empty().WithNavigate(nameof(ReplyPage)).Build()),
|
||
MainPageButtons.Files => Task.FromResult(PageResultBuilder.Empty().WithNavigate(nameof(FilesPage)).Build()),
|
||
_ => Task.FromResult(PageResultBuilder.Empty().WithText("Выберите действие с кнопок.").Build())
|
||
};
|
||
}
|
||
}
|
||
|
||
public enum MainPageButtons
|
||
{
|
||
[Action("📌 Inline")]
|
||
Inline,
|
||
|
||
[Action("⌨️ Reply")]
|
||
Reply,
|
||
|
||
[Action("📂 Файлы")]
|
||
Files,
|
||
}
|
||
}
|