public Task <bool> CanHandle(Update update) { if (_chatSession.ChatAdministrators.Any(x => x.ChatId == update.Message.Chat.Id)) { return(Task.FromResult(false)); } var message = update.Message.Text; if (string.IsNullOrWhiteSpace(message)) { return(Task.FromResult(false)); } var parts = message.Split(DataSeparator); if (parts.Length != 2) { return(Task.FromResult(false)); } var login = parts.Last(); var password = parts.First(); if (!(_chatSession.Login(update.Message.Chat, login, password) is { } user)) { return(Task.FromResult(false)); } _user = user; return(Task.FromResult(true)); }
private async Task <bool> SendSuccess(Message message, User user) { var deleteTask = _telegramBotClient.DeleteMessageAsync(message.Chat.Id, message.MessageId); var sendTask = _telegramBotClient.SendTextMessageAsync(message.Chat.Id, $"Successfully logged in using: ```{user.Email}```", ParseMode.MarkdownV2); await Task.WhenAll(deleteTask, sendTask); return(true); }