コード例 #1
0
ファイル: Bot.cs プロジェクト: Facebook-Incubator-EG/Iris
 private async void OnProducerUpdate(Update update)
 {
     _logger.LogInformation($"Caught new update: Id: {update.Id, -15}, Author: {update.Author.Id, -15}, Created at: {update.CreatedAt}");
     foreach (long chatId in _chatsManager.ChatIds.Keys)
     {
         await SendMessage(update, chatId);
     }
 }
コード例 #2
0
ファイル: Bot.cs プロジェクト: Facebook-Incubator-EG/Iris
        private async Task SendMessage(Update update, long chatId)
        {
            try
            {
                if (_validator.WasUpdateSent(update.Id, chatId))
                {
                    _logger.LogInformation($"Update #{update.Id} was already sent to chat #{chatId}");
                    return;
                }

                await _sender.SendAsync(update, chatId);

                _validator.UpdateSent(update.Id, chatId);

                _logger.LogInformation(
                    $"Sent new update: Id: {update.Id, -15}, ChatId: {update.Author.Id, -15}, Executed at: {DateTime.Now}");
            }
            catch (Exception e)
            {
                _logger.LogInformation(
                    e,
                    $"Failed to send update: Id: {update.Id, -15}, ChatId: {update.Author.Id, -15}, Executed at {DateTime.Now}");
            }
        }