コード例 #1
0
        protected override async Task <Message> SendResponseAsync(ICurrentTelegramUserClient client,
                                                                  InlineKeyboardButton[] response)
        {
            var(product, hookahs, tobaccos) = await TranslationsResolver.ResolveAsync(
                (TelegramTranslationKeys.ChooseProduct, Array.Empty <object>()),
                (TelegramTranslationKeys.Hookahs, Array.Empty <object>()),
                (TelegramTranslationKeys.Tobaccos, Array.Empty <object>())
                );

            return(await client
                   .SendTextMessageAsync(product,
                                         replyMarkup : new InlineKeyboardMarkup(new[]
            {
                new[]
                {
                    new InlineKeyboardButton
                    {
                        Text = hookahs,
                        CallbackData = $"/{nameof(GetHookahsCommand).ExtractCommandName()}"
                    },
                    new InlineKeyboardButton
                    {
                        Text = tobaccos,
                        CallbackData = $"/{nameof(GetTobaccosCommand).ExtractCommandName()}"
                    }
                },
                response
            }
                                                                                .ToArray())));
        }
コード例 #2
0
 protected override async Task <Message> SendResponseAsync(ICurrentTelegramUserClient client, Tobacco[] response)
 => await client
 .SendTextMessageAsync(response.Any()
                       ?response
                       .AggregateListString("/{0} {1} - {2}",
                                            x => x.Name,
                                            x => x.Price)
                       : await TranslationsResolver.ResolveAsync(TelegramTranslationKeys.NoTobaccos));
コード例 #3
0
 protected override async Task <Message> SendResponseAsync(ICurrentTelegramUserClient client)
 => await client
 .SendTextMessageAsync(await TranslationsResolver.ResolveAsync(TelegramTranslationKeys.Welcome),
                       replyMarkup : new ReplyKeyboardMarkup
 {
     OneTimeKeyboard = true,
     ResizeKeyboard  = true,
     Keyboard        = Array.Empty <IEnumerable <KeyboardButton> >()
 });
コード例 #4
0
        protected override async Task <Message> SendResponseAsync(ICurrentTelegramUserClient client,
                                                                  Order response)
        {
            var buttons           = new List <IEnumerable <InlineKeyboardButton> >();
            var firstLayerButtons = new List <InlineKeyboardButton>();
            var builder           = new StringBuilder();

            if (response.OrderedHookahs.Any() || response.OrderedTobaccos.Any())
            {
                builder.Append(StringifyResponse(response));
                if (response.State == OrderStates.Constructing)
                {
                    firstLayerButtons.Add(new InlineKeyboardButton
                    {
                        Text         = await TranslationsResolver.ResolveAsync(TelegramTranslationKeys.Confirm),
                        CallbackData = $"/{nameof(ConfirmOrderCommand).ExtractCommandName()} {response.Id}"
                    });
                }
            }
            else
            {
                builder.Append("seems like there is no any data in order");
            }

            builder.Append($"\n\nStatus: *{response.State}*");

            if (response.State == OrderStates.Constructing)
            {
                firstLayerButtons.Add(new InlineKeyboardButton
                {
                    Text         = await TranslationsResolver.ResolveAsync(TelegramTranslationKeys.Delete),
                    CallbackData = $"/{nameof(DeleteOrderCommand).ExtractCommandName()} {response.Id}"
                });
            }

            buttons.Add(firstLayerButtons);
            if (UserContextProvider.DatabaseUser.State > TelegramUserStates.Default)
            {
                buttons.Add(await GetServiceButtonsAsync(response));
            }

            return(await client
                   .SendTextMessageAsync(builder.ToString(),
                                         ParseMode.MarkdownV2,
                                         replyMarkup : new InlineKeyboardMarkup(buttons)));
        }
コード例 #5
0
        protected override async Task<Message> SendResponseAsync(ICurrentTelegramUserClient client,
            Identified<Tobacco> response)
        {
            var (content, keyboard) = await (
                TranslationsResolver.ResolveAsync(TelegramTranslationKeys.GetTobaccoResult, response.Entity.Name,
                    response.Entity.Price),
                PrepareKeyboardAsync(response)
            ).CombineAsync();

            if (response.Entity.Photos.Any())
            {
                await client.SendMediaGroupAsync(
                    response.Entity.Photos
                        .Select(x => new InputMediaPhoto(new InputMedia(x.TelegramFileId)))
                );
            }

            return await client
                .SendTextMessageAsync(
                    content,
                    replyMarkup: keyboard);
        }
コード例 #6
0
 protected override async Task <Message> SendResponseAsync(ICurrentTelegramUserClient client, Order response)
 => await client
 .SendTextMessageAsync(await TranslationsResolver.ResolveAsync(TelegramTranslationKeys.OrderHasBeenFinished, response.Id));
コード例 #7
0
 protected override Task <Message> SendResponseAsync(ICurrentTelegramUserClient client)
 => client
 .SendTextMessageAsync(() => TranslationsResolver.ResolveAsync(TelegramTranslationKeys.HookahRemoveSuccess));
コード例 #8
0
 protected override async Task <Message> SendResponseAsync(ICurrentTelegramUserClient client, Order response)
 => await client.SendTextMessageAsync(
     await TranslationsResolver.ResolveAsync(TelegramTranslationKeys.ConfirmOrderSuccess, response.Id));
コード例 #9
0
 protected override async Task <Message> SendResponseAsync(ICurrentTelegramUserClient client)
 => await client.SendTextMessageAsync(
     await TranslationsResolver
     .ResolveAsync(TelegramTranslationKeys.AddPhotoSuccess)
     );
コード例 #10
0
 protected override async Task <Message> SendResponseAsync(ICurrentTelegramUserClient client)
 => await client
 .SendTextMessageAsync(await TranslationsResolver.ResolveAsync(TelegramTranslationKeys.DeleteCommandSuccess, typeof(TEntity).Name));
コード例 #11
0
 protected override async Task <Message> SendResponseAsync(ICurrentTelegramUserClient client)
 => await client
 .SendTextMessageAsync(
     await TranslationsResolver.ResolveAsync(TelegramTranslationKeys.UserStateRegistrationSuccess,
                                             StateToSet.ToString().ToLower())
     );