Доработан формат подписи файлов
This commit is contained in:
@@ -20,7 +20,7 @@ public sealed class TelegramAlbumBuilder : IAlbumBuilder
|
||||
private readonly PageContext _ctx;
|
||||
private readonly ILogger _logger;
|
||||
private readonly TelegramBotClient? _client;
|
||||
private readonly List<(FileDescriptor file, string? caption)> _items = new();
|
||||
private readonly List<(FileDescriptor file, string? caption, MessageFormat? captionFormat)> _items = new();
|
||||
|
||||
/// <summary>Создать билдер альбома.</summary>
|
||||
public TelegramAlbumBuilder(TelegramAdapter adapter, PageContext ctx, ILogger logger, TelegramBotClient? client)
|
||||
@@ -32,9 +32,9 @@ public sealed class TelegramAlbumBuilder : IAlbumBuilder
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IAlbumBuilder Add(FileDescriptor file, string? caption = null)
|
||||
public IAlbumBuilder Add(FileDescriptor file, string? caption = null, MessageFormat? captionFormat = null)
|
||||
{
|
||||
_items.Add((file, caption));
|
||||
_items.Add((file, caption, captionFormat));
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -52,13 +52,13 @@ public sealed class TelegramAlbumBuilder : IAlbumBuilder
|
||||
if (!_adapter.Capabilities.SupportsAlbums)
|
||||
{
|
||||
_logger.Log(LogLevel.Warn, "Albums not supported. Degraded to sequential sends.");
|
||||
foreach (var (file, caption) in _items)
|
||||
await _adapter.SendFileAsync(_ctx.Update.Chat.Id, file, caption, ct);
|
||||
foreach (var (file, caption, captionFormat) in _items)
|
||||
await _adapter.SendFileAsync(_ctx.Update.Chat.Id, file, caption, captionFormat, ct);
|
||||
return;
|
||||
}
|
||||
|
||||
var media = new List<IAlbumInputMedia>();
|
||||
foreach (var (file, caption) in _items)
|
||||
foreach (var (file, caption, captionFormat) in _items)
|
||||
{
|
||||
Stream? stream = null;
|
||||
if (file.GetStreamAsync is not null)
|
||||
@@ -95,7 +95,7 @@ public sealed class TelegramAlbumBuilder : IAlbumBuilder
|
||||
{
|
||||
// Telegram не поддерживает document в альбомах — деградация
|
||||
_logger.Log(LogLevel.Warn, $"Document '{file.Kind}' in album not supported. Sending document separately.");
|
||||
await _adapter.SendFileAsync(_ctx.Update.Chat.Id, file, caption, ct);
|
||||
await _adapter.SendFileAsync(_ctx.Update.Chat.Id, file, caption, captionFormat, ct);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user