Убивает клиента ТГ, если он запущен вторым по токену
All checks were successful
CI / build-test (push) Successful in 37s
Release / pack-and-publish (release) Successful in 41s

This commit is contained in:
2025-12-10 20:31:04 +03:00
parent 8528b814d8
commit 644749929e

View File

@@ -10,6 +10,7 @@ using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Telegram.Bot; using Telegram.Bot;
using Telegram.Bot.Exceptions;
using Telegram.Bot.Types; using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums; using Telegram.Bot.Types.Enums;
using Telegram.Bot.Types.ReplyMarkups; using Telegram.Bot.Types.ReplyMarkups;
@@ -75,6 +76,15 @@ public sealed class TelegramAdapter : IMessangerAdapterSetup
errorHandler: async (_, ex, ct2) => errorHandler: async (_, ex, ct2) =>
{ {
_logger.Log(LogLevel.Warn, $"{MessengerType} error.", ex); _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; await Task.CompletedTask;
}, },