private async Task CommandAskQuestion(IDialogCommand cmd, ChatInfoEntity chatInfo, ITgOutboundMessage previousCmdAcknowledgement) { if (cmd == null) { return; } ITgOutboundMessage nextDlgQuestion = await cmd.AscUserAsync(chatInfo, _cancellationTokenSource.Token); ITgOutboundMessage botResponse = nextDlgQuestion; if (!string.IsNullOrWhiteSpace(previousCmdAcknowledgement?.Message)) { botResponse.Message = $"{previousCmdAcknowledgement.Message}{Environment.NewLine}{nextDlgQuestion.Message}"; } if (null != previousCmdAcknowledgement?.ReplyKeyboard) { botResponse.ReplyKeyboard = new ReplyKeyboardMarkup { Keyboard = botResponse.ReplyKeyboard?.Keyboard != null ? previousCmdAcknowledgement.ReplyKeyboard.Keyboard.Concat(botResponse.ReplyKeyboard.Keyboard) : previousCmdAcknowledgement.ReplyKeyboard?.Keyboard, OneTimeKeyboard = botResponse.ReplyKeyboard?.OneTimeKeyboard ?? true, ResizeKeyboard = botResponse.ReplyKeyboard?.ResizeKeyboard ?? true }; } await Task.Run(() => _botService.SendMessageAsync(chatInfo.ChatId, botResponse), _cancellationTokenSource.Token); }
private async Task <bool> SendMessages(SubscriptionEntity subscription, PlaybillChangeEntity[] changes) { string message = string.Join(Environment.NewLine, changes.Select(change => GetChangeDescription(subscription, change))); return(await _telegramService.SendMessageAsync(subscription.Id, message)); }