Files
BotPages/BotPages.Telegram/BotPagesAppExtension.cs

33 lines
1.2 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;
namespace BotPages.Telegram;
/// <summary>
/// Расширения для <see cref="BotPagesApp"/>.
/// </summary>
public static class BotPagesAppExtension
{
/// <summary>
/// Добавление адаптера для телеграмм в <see cref="BotPages.Core.Abstractions.IMessengerAdapterFactory"/>
/// </summary>
/// <param name="app"></param>
/// <param name="token"></param>
/// <param name="messengerType"></param>
/// <returns></returns>
public static BotPagesApp AddTelegramAdapter(this BotPagesApp app, string token, string messengerType = "")
=> app.AddTelegramAdapter(token, null, messengerType);
/// <summary>
/// Добавление адаптера для телеграмм с опциями.
/// </summary>
public static BotPagesApp AddTelegramAdapter(this BotPagesApp app, string token, TelegramOptions? options, string messengerType = "")
{
var telegram = new TelegramAdapter(app.Logger, token, options);
if (!string.IsNullOrWhiteSpace(messengerType)) telegram.MessengerType = messengerType;
app.AddAdapter(telegram.MessengerType, telegram);
return app;
}
}