public static void Create(MessagingPlatform messagingPlatform) { try { IConsumeMessage consumeMessage = new ConsumeMessage(); while (true) { Thread.Sleep(1000); string consumedMessage = consumeMessage.ConsumeMessages(Environment.GetEnvironmentVariable("queueName")); if (!string.IsNullOrEmpty(consumedMessage)) { RabbitMQResponse response = RabbitMQResponse.Create(consumedMessage); ExceptionChat = response.Payload.ChatId; _telegramBotClient.SendTextMessageAsync(response.Payload.ChatId, response.Payload.Message).GetAwaiter().GetResult(); } GC.Collect(); } } catch (Exception ex) { new ExceptionResponsibility(ex, messagingPlatform); Console.WriteLine(ex.ToString()); Create(messagingPlatform); } }
public BotKickedException(Exception exception, MessagingPlatform messagingPlatform) { if (exception.Message.Equals(BOT_KICKED)) { IQueryRssChatRelationService queryRssChatRelationService = messagingPlatform.Resolve <IQueryRssChatRelationService>(); ICommandRssChatRelationService commandRssChatRelationService = messagingPlatform.Resolve <ICommandRssChatRelationService>(); Response <IList <RssChatRelationEntity> > response = queryRssChatRelationService.GetList(LifeTimeCycle.LifeTimeCycle.ExceptionChat); foreach (var item in response.ResponseData) { commandRssChatRelationService.Remove(item); } return; } //new Exception(exception); }
public ExceptionResponsibility(Exception exception, MessagingPlatform messagingPlatform) { new BotKickedException(exception, messagingPlatform); }