Убивает клиента ТГ, если он запущен вторым по токену
This commit is contained in:
@@ -10,6 +10,7 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Exceptions;
|
||||
using Telegram.Bot.Types;
|
||||
using Telegram.Bot.Types.Enums;
|
||||
using Telegram.Bot.Types.ReplyMarkups;
|
||||
@@ -75,6 +76,15 @@ public sealed class TelegramAdapter : IMessangerAdapterSetup
|
||||
errorHandler: async (_, ex, ct2) =>
|
||||
{
|
||||
_logger.Log(LogLevel.Warn, $"{MessengerType} error.", ex);
|
||||
|
||||
if (ex is ApiRequestException apiEx)
|
||||
{
|
||||
if (apiEx.ErrorCode == 409)
|
||||
{
|
||||
_logger.Log(LogLevel.Critical, $"{MessengerType} остановлен.");
|
||||
await _.Close(ct2);
|
||||
}
|
||||
}
|
||||
await Task.CompletedTask;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user