Files
BotPages/BotPages.Core/Abstractions/IMessengerAdapter.cs
2025-12-24 05:55:26 +03:00

63 lines
2.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using BotPages.Core.Context;
using BotPages.Core.Messaging;
namespace BotPages.Core.Abstractions;
/// <summary>
/// Контракт адаптера мессенджера.
/// Определяет операции отправки сообщений, файлов и прогресса.
/// </summary>
public interface IMessengerAdapter
{
/// <summary>
/// Доступные возможности мессенджера.
/// </summary>
Capabilities Capabilities { get; }
/// <summary>
/// Отправить текстовое сообщение в чат.
/// </summary>
Task<string?> SendTextAsync(string chatId,
string text,
MessageFormat format = MessageFormat.Plain,
IEnumerable<IEnumerable<InlineButton>>? inline = null,
IEnumerable<IEnumerable<ReplyButton>>? reply = null,
string? messageId = null,
CancellationToken ct = default
);
/// <summary>
/// Отправить файл в чат.
/// </summary>
Task SendFileAsync(string chatId,
FileDescriptor file,
string? caption = null,
MessageFormat? captionFormat = null,
IEnumerable<IEnumerable<InlineButton>>? inline = null,
IEnumerable<IEnumerable<ReplyButton>>? reply = null,
CancellationToken ct = default);
/// <summary>
/// Создать билдер альбома для отправки медиагруппы.
/// </summary>
IAlbumBuilder CreateAlbumBuilder(PageContext ctx);
/// <summary>
/// Вызывается при выходе со страницы.
/// </summary>
Task OnLeaveAsync(PageContext ctx, CancellationToken ct);
}
/// <summary>
/// Контракт конфигурации адаптера.
/// </summary>
public interface IMessengerAdapterSetup : IMessengerAdapter
{
/// <summary>
/// Запуск работы адаптера
/// </summary>
/// <param name="onUpdate"></param>
/// <param name="ct"></param>
/// <returns></returns>
Task StartAdapterAsync(Func<UpdateContext, Task> onUpdate, List<Routing.Command> commands, CancellationToken ct);
}