This commit is contained in:
29
Demo/Pages/FileSendPage.cs
Normal file
29
Demo/Pages/FileSendPage.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using BotPages.Core;
|
||||
using BotPages.Core.Abstractions;
|
||||
using BotPages.Core.Messaging;
|
||||
|
||||
namespace Demo.Pages;
|
||||
|
||||
public sealed class FileSendPage : SingletonPage
|
||||
{
|
||||
public override 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)
|
||||
};
|
||||
|
||||
return new MessageBuilder(ctx)
|
||||
.Text("Вот пример отправки нового файла 📎", MessageFormat.Markdown)
|
||||
.File(demoFile, "Демонстрационный файл")
|
||||
.SendAsync(ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user