Убраны старые api
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
using BotPages.Core.Abstractions;
|
||||
using BotPages.Core.Context;
|
||||
using BotPages.Core.Logging;
|
||||
using BotPages.Core.Messaging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -23,6 +22,8 @@ namespace BotPages.Telegram;
|
||||
/// </summary>
|
||||
public sealed class TelegramAdapter : IMessengerAdapterSetup
|
||||
{
|
||||
internal static readonly string AdapterType = typeof(TelegramAdapter).FullName;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private TelegramBotClient? _client;
|
||||
private string _token;
|
||||
@@ -104,9 +105,9 @@ public sealed class TelegramAdapter : IMessengerAdapterSetup
|
||||
return null;
|
||||
}
|
||||
|
||||
// determine adapter-specific options (TelegramOptions) from bag or use adapter default
|
||||
// Определите параметры адаптера (TelegramOptions) из папки или используйте параметры адаптера по умолчанию.
|
||||
TelegramOptions telegramOptions = _options;
|
||||
if (req.AdapterOptions is AdapterOptionsBag bag && bag.TryGet("telegram", out TelegramOptions? opt) && opt is not null)
|
||||
if (req.AdapterOptions is AdapterOptionsBag bag && bag.TryGet(AdapterType, out TelegramOptions? opt) && opt is not null)
|
||||
{
|
||||
telegramOptions = opt;
|
||||
}
|
||||
@@ -137,7 +138,7 @@ public sealed class TelegramAdapter : IMessengerAdapterSetup
|
||||
}
|
||||
}
|
||||
|
||||
// If there is a file — send file
|
||||
// Если есть файл - отправить файл
|
||||
if (req.File is not null)
|
||||
{
|
||||
var file = req.File;
|
||||
@@ -193,7 +194,7 @@ public sealed class TelegramAdapter : IMessengerAdapterSetup
|
||||
return sentMessage?.MessageId.ToString();
|
||||
}
|
||||
|
||||
// Otherwise treat as text
|
||||
// Иначе - отправить текст
|
||||
if (!string.IsNullOrWhiteSpace(req.Text))
|
||||
{
|
||||
var format = req.TextFormat ?? MessageFormat.Plain;
|
||||
@@ -254,54 +255,6 @@ public sealed class TelegramAdapter : IMessengerAdapterSetup
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<string?> SendTextAsync(string chatId, string text,
|
||||
MessageFormat format = MessageFormat.Plain,
|
||||
IEnumerable<IEnumerable<InlineButton>>? inline = null,
|
||||
IEnumerable<IEnumerable<ReplyButton>>? reply = null,
|
||||
string? messageId = null,
|
||||
object? adapterOptions = null,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
var req = new SendRequest
|
||||
{
|
||||
ChatId = chatId,
|
||||
Text = text,
|
||||
TextFormat = format,
|
||||
Inline = inline,
|
||||
Reply = reply,
|
||||
MessageId = messageId,
|
||||
AdapterOptions = adapterOptions as AdapterOptionsBag
|
||||
};
|
||||
|
||||
return SendAsync(req, ct);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task SendFileAsync(string chatId,
|
||||
FileDescriptor file,
|
||||
string? caption = null,
|
||||
MessageFormat? captionFormat = null,
|
||||
IEnumerable<IEnumerable<InlineButton>>? inline = null,
|
||||
IEnumerable<IEnumerable<ReplyButton>>? reply = null,
|
||||
object? adapterOptions = null,
|
||||
CancellationToken ct = default
|
||||
)
|
||||
{
|
||||
var req = new SendRequest
|
||||
{
|
||||
ChatId = chatId,
|
||||
File = file,
|
||||
Caption = caption,
|
||||
CaptionFormat = captionFormat,
|
||||
Inline = inline,
|
||||
Reply = reply,
|
||||
AdapterOptions = adapterOptions as AdapterOptionsBag
|
||||
};
|
||||
|
||||
return SendAsync(req, ct);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IAlbumBuilder CreateAlbumBuilder(PageContext ctx) => new TelegramAlbumBuilder(this, ctx, _logger, _client);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user