Files
BotPages/BotPages.Core/Abstractions/IMessengerAdapter.cs
FrigaT a94327f0c8
All checks were successful
CI / build-test (push) Successful in 33s
Release / pack-and-publish (release) Successful in 38s
Доработан стартер адаптеров
2025-12-05 18:06:12 +03:00

57 lines
2.0 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>
Task SendTextAsync(PageContext ctx, string text, MessageFormat format,
IEnumerable<IEnumerable<InlineButton>>? inline,
IEnumerable<IEnumerable<ReplyButton>>? reply, CancellationToken ct);
/// <summary>
/// Отправить файл в чат.
/// </summary>
Task SendFileAsync(PageContext ctx, 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);
}