34 lines
1.0 KiB
C#
34 lines
1.0 KiB
C#
using BotPages.Core;
|
|
using BotPages.Core.Abstractions;
|
|
using BotPages.Core.Messaging;
|
|
using BotPages.Core.Routing;
|
|
|
|
namespace Demo.Pages;
|
|
|
|
[Route("FileSend")]
|
|
public sealed class FileSendPage : SingletonPage
|
|
{
|
|
public override async Task OnEnter(PageContext ctx, CancellationToken ct)
|
|
{
|
|
var content = "Hello from BotPages! This file is generated on the fly.";
|
|
var stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(content));
|
|
|
|
var demoFile = new FileDescriptor
|
|
{
|
|
Id = "",
|
|
Name = "demo.txt",
|
|
Extension = "txt",
|
|
Size = stream.Length,
|
|
Kind = FileKind.Document,
|
|
GetStreamAsync = _ => Task.FromResult<Stream>(stream)
|
|
};
|
|
|
|
var msg = await new MessageBuilder(ctx)
|
|
.Text("Вот пример отправки нового файла 📎", MessageFormat.Markdown)
|
|
.File(demoFile, "Демонстрационный файл")
|
|
.SendAsync(ct);
|
|
|
|
await ctx.GoToHomeAsync(ct);
|
|
}
|
|
}
|