Добавьте файлы проекта.
This commit is contained in:
39
Demo/Pages/FilesPage.cs
Normal file
39
Demo/Pages/FilesPage.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
35
Demo/Pages/InlinePage.cs
Normal file
35
Demo/Pages/InlinePage.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using BotPages.Core;
|
||||
|
||||
namespace Demo.Pages
|
||||
{
|
||||
public sealed class InlinePage : Page
|
||||
{
|
||||
public override string Id => nameof(InlinePage);
|
||||
|
||||
public override Task<PageResult> EnterAsync(UpdateContext ctx, CancellationToken ct)
|
||||
{
|
||||
var actions = new[]
|
||||
{
|
||||
new PageAction { Label = "⬅️ Назад", Value = "back", Placement = ActionPlacement.Inline, Row = 0 }
|
||||
};
|
||||
|
||||
return Task.FromResult(
|
||||
PageResultBuilder.Empty()
|
||||
.WithText("Это страница с Inline‑кнопками.")
|
||||
.WithKeyboard(actions)
|
||||
.Build()
|
||||
);
|
||||
}
|
||||
|
||||
public override Task<PageResult> HandleAsync(UpdateContext ctx, CancellationToken ct)
|
||||
{
|
||||
if (ctx.Text == "back")
|
||||
return Task.FromResult(PageResultBuilder.Empty().WithNavigate(nameof(MainPage)).Build());
|
||||
|
||||
return Task.FromResult(PageResultBuilder.Empty().WithText("Нажмите кнопку 'Назад'.").Build());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
38
Demo/Pages/MainPage.cs
Normal file
38
Demo/Pages/MainPage.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
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 { Label = "📌 Inline", Value = "inline", Placement = ActionPlacement.Reply, Row = 0 },
|
||||
new PageAction { Label = "⌨️ Reply", Value = "reply", Placement = ActionPlacement.Reply, Row = 1 },
|
||||
new PageAction { Label = "📂 Файлы", Value = "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)
|
||||
{
|
||||
return ctx.Text switch
|
||||
{
|
||||
"📌 Inline" => Task.FromResult(PageResultBuilder.Empty().WithNavigate(nameof(InlinePage)).Build()),
|
||||
"⌨️ Reply" => Task.FromResult(PageResultBuilder.Empty().WithNavigate(nameof(ReplyPage)).Build()),
|
||||
"📂 Файлы" => Task.FromResult(PageResultBuilder.Empty().WithNavigate(nameof(FilesPage)).Build()),
|
||||
_ => Task.FromResult(PageResultBuilder.Empty().WithText("Выберите действие с кнопок.").Build())
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
33
Demo/Pages/ReplyPage.cs
Normal file
33
Demo/Pages/ReplyPage.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using BotPages.Core;
|
||||
|
||||
namespace Demo.Pages
|
||||
{
|
||||
public sealed class ReplyPage : Page
|
||||
{
|
||||
public override string Id => nameof(ReplyPage);
|
||||
|
||||
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("Это страница с Reply‑клавиатурой.")
|
||||
.WithKeyboard(actions)
|
||||
.Build()
|
||||
);
|
||||
}
|
||||
|
||||
public override Task<PageResult> HandleAsync(UpdateContext ctx, CancellationToken ct)
|
||||
{
|
||||
if (ctx.Text == "⬅️ Назад")
|
||||
return Task.FromResult(PageResultBuilder.Empty().WithNavigate(nameof(MainPage)).Build());
|
||||
|
||||
return Task.FromResult(PageResultBuilder.Empty().WithText("Нажмите кнопку 'Назад'.").Build());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user