private async Task <MessageForSendDto> CreateMessageForSend(Message message) { var messageForSend = new MessageForSendDto() { chat_id = message.chat.id }; switch (message.text.ToLower()) { case "/start": messageForSend.text = "Наберите валютную пару Binance или " + "выберите из примерных предложенных."; messageForSend.reply_markup = GetButtons(message.chat.id); break; default: string symbol = message.text.ToUpper(); string url = Binance24hrUrl.Replace("pair", symbol); try { var get24hrTicker = new ApiGetingData <_24hrTickerDto>(_logger); var ticker = await get24hrTicker.GetDataAsync(url); messageForSend.text = ticker.ToString(); await LogInformation(ticker.ToString()); } catch (Exception ex) { await LogInformation(ex.Message); messageForSend.text = $"Пары {message.text} на Binance не существует"; } break; } return(messageForSend); }
public async Task <MessageForSendDto <object> > CreateMessageForSend(MessageDto message) { MessageForSendDto <object> messageForSend; var chatId = message.Chat.Id; var messageText = message.Text; switch (messageText.ToLower()) { case "/start": messageForSend = new MessageForSendDto <object>() { ChatId = chatId, Text = "Наберите валютную пару Binance или " + "выберите из примерных предложенных.", ReplyMarkup = GetButtons(chatId) }; break; case "/remove": messageForSend = new MessageForSendDto <object>() { ChatId = chatId, Text = "Удаление клавиатуры", ReplyMarkup = new TelegramRemoveButtons() }; break; case "/inline": messageForSend = new MessageForSendDto <object>() { ChatId = chatId, Text = "inline menu", ReplyMarkup = GetInlineButtons(chatId) }; break; default: string symbol = messageText.ToUpper(); string url = Binance24hrUrl.Replace("pair", symbol); messageForSend = new MessageForSendDto <object>() { ChatId = chatId }; try { var apiLogger = _logger as MyLogger <ApiGetingData <_24hrTickerDto> >; var get24hrTicker = new ApiGetingData <_24hrTickerDto>(apiLogger); var ticker = await get24hrTicker.GetDataAsync(url); messageForSend.Text = ticker.ToString(); await _logger.LogInformation(ticker.ToString()); } catch (Exception ex) { await _logger.LogInformation(ex.Message); messageForSend.Text = $"Пары на Binance {messageText} не существует"; } break; } return(messageForSend); }
public async Task <string> SendMessage <TButton>(MessageForSendDto <TButton> message) where TButton : class { string url = GetUrl("sendMessage"); return(await SendRequest(url, message)); }
public static bool isEqual <T>( this MessageForSendDto <T> messageForSendDto, MessageDto incomingMessageDto) where T : class { return((messageForSendDto.Text == incomingMessageDto.Text) && (messageForSendDto.ReplyMarkup == incomingMessageDto.ReplyMarkup) && (messageForSendDto.ChatId == incomingMessageDto.Chat.Id)); }
public async Task <string> SendView <T>( MessageForSendDto <T> messageForSendDto, MessageDto incomingMessageDto) where T : class { long userId = incomingMessageDto.From.Id; if (messageForSendDto.isEqual(incomingMessageDto)) { return(""); } var response = await _telegramRequest.SendMessage(messageForSendDto) ?? ""; //await _backwardRepository.SetBackwardView(userId, messageForSendDto); await _logger.LogSentToUser(messageForSendDto); return(response); }
public async Task LogSentToUser <TButton>(MessageForSendDto <TButton> messageDto) where TButton : class { await LogInformation("Was SENT TO USER\n" + messageDto.GetDump()); }
public async Task <byte[]> SendMessage(MessageForSendDto message) { string url = GetUrl("sendMessage"); return(await SendRequest(url, message)); }