public async Task Handle(ITelegramBotClient client, Message message, CancellationToken cancellationToken) { var exists = await _userRepository.ExistsAsync(message.From.Id, cancellationToken); if (!exists) { await client.SendTextMessageAsync( chatId : message.Chat, text : L10n.strings.DontKnowYouMessage, replyToMessageId : message.MessageId, cancellationToken : cancellationToken ); return; } _session.Add(message, message.From.Id, SessionScope.Stop); var inlineKeyboard = new InlineKeyboardMarkup(new[] { new [] { InlineKeyboardButton.WithCallbackData(L10n.strings.YesText, L10n.strings.YesKeyword), InlineKeyboardButton.WithCallbackData(L10n.strings.NoText, L10n.strings.NoKeyword), } }); var sent = await client.SendTextMessageAsync( chatId : message.Chat, text : L10n.strings.StopBotConfirmationMessage, replyMarkup : inlineKeyboard, cancellationToken : cancellationToken ); _session.Add(sent, message.From.Id, SessionScope.Stop); }
public async Task Handle(ITelegramBotClient client, Message message, CancellationToken cancellationToken) { await client.SendChatActionAsync(message.Chat, ChatAction.Typing, cancellationToken); var userExists = await _userRepository.ExistsAsync(message.From.Id, cancellationToken); var session = _session.Get(message.Chat.Id); if (userExists || session != null) { await client.SendTextMessageAsync( chatId : message.Chat, text : L10n.strings.WeHaveAlreadyMetMessage, parseMode : ParseMode.Markdown, replyToMessageId : message.MessageId, cancellationToken : cancellationToken ); return; } await client.SendTextMessageAsync( chatId : message.Chat, text : L10n.strings.WelcomeMessage, parseMode : ParseMode.Markdown, cancellationToken : cancellationToken ); await Task.Delay(_settings.ConsecutiveMessagesInterval, cancellationToken); var sent = await client.SendTextMessageAsync( chatId : message.Chat, text : L10n.strings.SendUsernameAndPasswordMessage, parseMode : ParseMode.Markdown, replyMarkup : new ForceReplyMarkup() { InputFieldPlaceholder = L10n.strings.UsernameAndPasswordPlaceholder }, cancellationToken : cancellationToken ); _session.Add(sent, message.From.Id, SessionScope.Login); }