Ejemplo n.º 1
0
        public async Task Handle(ITelegramBotClient client, Message message, CancellationToken cancellationToken)
        {
            var user = await _userCache.GetUserAsync(message.From.Id, cancellationToken);

            if (user is null)
            {
                await client.SendTextMessageAsync(
                    chatId : message.Chat,
                    text : L10n.strings.DontKnowYouMessage,
                    replyToMessageId : message.MessageId,
                    cancellationToken : cancellationToken
                    );

                return;
            }

            if (user is SecondaryUser secondaryUser)
            {
                user = await _userCache.GetLoggedUserAsync(secondaryUser, cancellationToken);
            }

            if (user is LoggedUser loggedUser)
            {
                var packages = await _flypack.LoginAndFetchPackagesAsync(loggedUser.Username, _decrypter.Decrypt(loggedUser.Password, loggedUser.Salt));
                await SendPackagesToChat(client, packages, message.Chat.Id, cancellationToken);
            }
        }