Files
BotPages/BotPages.Core/Messaging/MessageBuilderAdapterExtensions.cs

55 lines
2.4 KiB
C#
Raw Permalink 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.Abstractions;
namespace BotPages.Core.Messaging;
/// <summary>
/// Расширения для MessageBuilder для работы с разными адаптерами.
/// </summary>
public static class MessageBuilderAdapterExtensions
{
/// <summary>
/// Отправить сообщение через конкретный адаптер.
/// </summary>
public static MessageBuilder WithAdapter(this MessageBuilder builder, IMessengerAdapter adapter)
{
builder.WithAdapter(adapter);
return builder;
}
/// <summary>
/// Отправить сообщение через адаптер по типу и ID экземпляра.
/// </summary>
public static MessageBuilder WithAdapter(this MessageBuilder builder, string messengerType, string instanceId)
{
// Получаем фабрику адаптеров через сервис локатор или контекст
// В реальной реализации нужно будет передать фабрику адаптеров
return builder;
}
/// <summary>
/// Отправить сообщение через адаптер по полному ключу.
/// </summary>
public static MessageBuilder WithAdapter(this MessageBuilder builder, string fullMessengerKey)
{
// В реальной реализации нужно будет передать фабрику адаптеров
return builder;
}
/// <summary>
/// Отправить сообщение в указанный чат с указанным адаптером.
/// </summary>
public static MessageBuilder ToChat(this MessageBuilder builder, string chatId, IMessengerAdapter adapter)
{
return builder.ToChat(chatId, adapter);
}
/// <summary>
/// Отправить сообщение в чат в другом адаптере того же типа.
/// </summary>
public static MessageBuilder ToChatInOtherInstance(this MessageBuilder builder, string chatId, string instanceId)
{
// Получаем тип текущего адаптера и используем другой экземпляр
// В реальной реализации нужно будет передать фабрику адаптеров
return builder;
}
}