Files
BotPages/BotPages.Core/Abstractions/IMessengerAdapter.cs
2025-12-05 19:45:59 +03:00

59 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
{
Capabilities Capabilities { get; }
/// <summary>
/// Отправить текстовое сообщение в чат.
/// </summary>
Task SendTextAsync(string chatId, string text, MessageFormat format,
IEnumerable<IEnumerable<InlineButton>>? inline,
IEnumerable<IEnumerable<ReplyButton>>? reply, CancellationToken ct);
/// <summary>
/// Отправить файл в чат.
/// </summary>
Task SendFileAsync(string chatId, FileDescriptor file, string? caption, CancellationToken ct);
/// <summary>
/// Создать билдер альбома для отправки медиагруппы.
/// </summary>
IAlbumBuilder CreateAlbumBuilder(PageContext ctx);
/// <summary>
/// Начать отображение прогресса операции.
/// </summary>
Task<string?> StartProgressAsync(PageContext ctx, string title, CancellationToken ct);
/// <summary>
/// Обновить прогресс операции.
/// </summary>
Task UpdateProgressAsync(PageContext ctx, string messageId, string title, int percent, CancellationToken ct);
/// <summary>
/// Вызывается при выходе со страницы.
/// </summary>
Task OnLeaveAsync(PageContext ctx, CancellationToken ct);
}
/// <summary>
/// Контракт конфигурации адаптера.
/// </summary>
public interface IMessangerAdapterSetup : IMessengerAdapter
{
/// <summary>
/// Запуск работы адаптера
/// </summary>
/// <param name="onUpdate"></param>
/// <param name="ct"></param>
/// <returns></returns>
Task StartAdapterAsync(Func<UpdateContext, Task> onUpdate, CancellationToken ct);
}