33 lines
1.2 KiB
C#
33 lines
1.2 KiB
C#
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;
|
||
}
|
||
}
|