Beispiel #1
0
        public static IEnumerable <KeyValuePair <string, IReplyMarkup> > GetFormattedResponse(IEnumerable <DownloadLink> downloadLinks)
        {
            if (!downloadLinks.Any())
            {
                return(new[]
                {
                    // 'try again (repeat)' button
                    new KeyValuePair <string, IReplyMarkup>(
                        "_Sorry, it looks like there are no download links available for this video =(_",
                        InlineKeyboardMarkup.Empty())
                });
            }

            var response = new List <KeyValuePair <string, IReplyMarkup> >();

            var fileTypes = downloadLinks.GroupBy(x => x.FileFormat);

            foreach (var fileType in fileTypes)
            {
                var    markup      = GetKeyboard(fileType);
                string messageText = $"Download **{fileType.Key}**";

                response.Add(new KeyValuePair <string, IReplyMarkup>(messageText, markup));
            }

            return(response);
        }
Beispiel #2
0
        public async Task HandleAsync(IUpdateContext context, UpdateDelegate next, CancellationToken cancellationToken)
        {
            UpdateType updateType = context?.Update?.Type ?? UpdateType.Unknown;

            switch (updateType)
            {
            case UpdateType.Message:
            {
                await context.Bot.Client.SendTextMessageAsync(
                    chatId : context.Update.Message.Chat.Id,
                    text : "Searching through tips .."
                    );

                break;
            }

            case UpdateType.CallbackQuery:
            {
                await context.Bot.Client.EditMessageTextAsync(
                    chatId : context.Update.CallbackQuery.Message.Chat.Id,
                    messageId : context.Update.CallbackQuery.Message.MessageId,
                    text : "Searching through tips ..",
                    replyMarkup : InlineKeyboardMarkup.Empty()
                    );

                break;
            }
            }
        }
Beispiel #3
0
        protected async Task Exit(IUpdateContext context)
        {
            this.Cache.RemoveTask(context.Update.ToUserchat());

            // закрыть инлайн меню и вызвать меню стартовой страницы
            await RefreshInlineMenu(context, InlineKeyboardMarkup.Empty()).ConfigureAwait(false);
        }
Beispiel #4
0
 private async Task EditCallbackMessage(CommandContext context)
 {
     if (context.Message != null && context.Message.ReplyMarkup != InlineKeyboardMarkup.Empty())
     {
         await BotClient.EditMessageReplyMarkupAsync(context.Message.Chat, context.Message.MessageId, InlineKeyboardMarkup.Empty());
     }
     context.RedirectToCommand($"/select{context.Parameters}");
 }
    public async Task <ButtonParsed> GetFeatureConfig(string featureName)
    {
        var config = _featureConfig.Items?.FirstOrDefault(item => item.Key == featureName);

        var buttonMarkup = InlineKeyboardMarkup.Empty();

        var buttonParsed = new ButtonParsed
        {
            FeatureName = featureName,
            Markup      = buttonMarkup
        };

        if (config == null)
        {
            _logger.LogWarning("ButtonConfig Not Found: {Key}", featureName);
            return(buttonParsed);
        }

        var currentEnvironment = await _botService.CurrentEnvironment();

        var mergedCaption = config.Captions?
                            .Where(caption => caption.MinimumLevel <= currentEnvironment)
                            .Select(caption => caption.Sections.JoinStr(" "))
                            .JoinStr("\n\n");

        List <IEnumerable <InlineKeyboardButton> > button = null;

        if (config.Buttons != null)
        {
            button = config
                     .Buttons
                     .Select
                     (
                x => x
                .Select(y => InlineKeyboardButton.WithUrl(y.Text, y.Url.ToString()))
                     )
                     .ToList();

            buttonMarkup = new InlineKeyboardMarkup(button);
        }

        buttonParsed.IsEnabled = config.IsEnabled;
        buttonParsed.AllowsAt  = config.AllowsAt;
        buttonParsed.ExceptsAt = config.ExceptsAt;

        buttonParsed.Caption        = mergedCaption;
        buttonParsed.Markup         = buttonMarkup;
        buttonParsed.KeyboardButton = button;

        buttonParsed.IsApplyRateLimit = config.RateLimitSpan != null;
        if (buttonParsed.IsApplyRateLimit)
        {
            buttonParsed.RateLimitTimeSpan = config.RateLimitSpan.ToTimeSpan();
            buttonParsed.NextAvailable     = buttonParsed.RateLimitTimeSpan.ToDateTime(useUtc: true);
        }

        return(buttonParsed);
    }
        public static Task ClearLastKeyboard(this TelegramBotClient client, Message message,
                                             CancellationToken cancellationToken = default)
        {
            long chatId           = message.Chat.Id;
            int  requestMessageId = message.MessageId;

            // remove navigation controls from the current message
            return(client.EditMessageReplyMarkupAsync(chatId, requestMessageId, InlineKeyboardMarkup.Empty(),
                                                      cancellationToken));
        }
Beispiel #7
0
        public async Task HandleAsync(IUpdateContext context, UpdateDelegate next)
        {
            var queryData = context.Update.CallbackQuery.Data;
            var type      = queryData.Substring(Constants.SelectedOption.Length).ToInt();

            switch (type)
            {
            case 0:
            {
                var calendarMarkup = CalendarPicker.CalendarControl.Markup.Calendar(DateTime.Today,
                                                                                    new CultureInfo("ru-RU", false).DateTimeFormat);

                var calendarWithCancelMakup = new InlineKeyboardMarkup(calendarMarkup.InlineKeyboard
                                                                       .Prepend(new[]
                                                                                { InlineKeyboardButton.WithCallbackData("На выбор таска", $"{Constants.RootPage}0:") }));

                var task = this.Cache.GetTask(context.Update.ToUserchat());

                await RefreshInlineMenu(context, calendarWithCancelMakup,
                                        $"Выбирите дату дедлайна (текущий {task.DeadlineDate:d})").ConfigureAwait(false);

                break;
            }

            case 1:
            {
                await RefreshInlineMenu(context, InlineKeyboardMarkup.Empty(), $"Увеличить время выполнение на: (вписать кол-во часов)");

                //var resources = await this.DemoService.GetAllUsers();

                //var resorceTitles = resources.Select(r => r.Username).ToArray();

                //var inlineKeyboard = Markup.CreateTaskResourceInlineKeyboard(resorceTitles);
                //await RefreshInlineMenu(context, inlineKeyboard, "Выбирите исполнителя").ConfigureAwait(false);

                break;
            }

            case 2:
            {
                await RefreshInlineMenu(context, InlineKeyboardMarkup.Empty(), $"Увеличить время выполнение на: (вписать кол-во часов)");

                break;
            }

            default:
                break;
            }
        }
        private async Task ProcessCallback(CommandContext context)
        {
            if (context.Message != null && context.Message.ReplyMarkup != InlineKeyboardMarkup.Empty())
            {
                await BotClient.EditMessageReplyMarkupAsync(context.Message.Chat, context.Message.MessageId, InlineKeyboardMarkup.Empty());

                string command;
                if (string.IsNullOrEmpty(context.Parameters))
                {
                    command = "/remove";
                }
                else
                {
                    command = $"/edit{context.Parameters}";
                }

                context.RedirectToCommand(command);
            }
        }
Beispiel #9
0
    public static InlineKeyboardMarkup ToButtonMarkup(this List <List <ButtonMarkup> > rawButtonMarkups)
    {
        var buttonMarkup = InlineKeyboardMarkup.Empty();

        if (rawButtonMarkups != null)
        {
            buttonMarkup = new InlineKeyboardMarkup
                           (
                rawButtonMarkups
                .Select
                (
                    x => x
                    .Select(y => InlineKeyboardButton.WithUrl(y.Text, y.Url))
                )
                           );
        }

        return(buttonMarkup);
    }
Beispiel #10
0
    public async Task <ButtonParsed> GetButtonConfig(string key)
    {
        var items = GetButtonConfigAll();
        var item  = items.FirstOrDefault(buttonItem => buttonItem.Key == key);

        var buttonMarkup = InlineKeyboardMarkup.Empty();

        var buttonParsed = new ButtonParsed
        {
            Markup = buttonMarkup
        };

        if (item == null)
        {
            _logger.LogWarning("ButtonConfig Not Found: {Key}", key);
            return(buttonParsed);
        }

        var currentEnvironment = await CurrentEnvironment();

        var mergedCaption = item.Data?.Captions?
                            .Where(caption => caption.MinimumLevel <= currentEnvironment)
                            .Select(caption => caption.Sections.JoinStr("\n\n"))
                            .JoinStr("\n\n");

        if (item?.Data?.Buttons != null)
        {
            buttonMarkup = new InlineKeyboardMarkup(
                item
                .Data
                .Buttons
                .Select(
                    x => x
                    .Select(y => InlineKeyboardButton.WithUrl(y.Text, y.Url))
                    )
                );
        }

        buttonParsed.Caption = mergedCaption;
        buttonParsed.Markup  = buttonMarkup;

        return(buttonParsed);
    }
        public async Task HandleAsync(IUpdateContext context, UpdateDelegate next, CancellationToken cancellationToken)
        {
            int count = FractionsInfoWiki.Available.Count;

            if (count <= 0)
            {
                return;
            }

            //  Get random fraction info
            int           randomFractionInfo = Randomizer.Instance.Next(0, count);
            IFractionInfo fractionInfo       = FractionsInfoWiki.Available[randomFractionInfo];

            long       chatId;
            UpdateType updateType = context?.Update?.Type ?? UpdateType.Unknown;

            if (updateType == UpdateType.CallbackQuery)
            {
                chatId = context.Update.CallbackQuery.Message.Chat.Id;
                await context.Bot.Client.EditMessageTextAsync(
                    chatId : chatId,
                    messageId : context.Update.CallbackQuery.Message.MessageId,
                    text : fractionInfo.Topic,
                    replyMarkup : InlineKeyboardMarkup.Empty()
                    );
            }
            else
            {
                chatId = context.Update.Message.Chat.Id;
                await context.Bot.Client.SendTextMessageAsync(
                    chatId : chatId,
                    text : fractionInfo.Topic
                    );
            }

            foreach (string fractionInfoItem in FractionsInfoHandler.FormatFractionInfo(fractionInfo))
            {
                await context.Bot.Client.SendTextMessageAsync(
                    chatId : chatId,
                    text : fractionInfoItem
                    );
            }
        }
Beispiel #12
0
        public async Task Should_Edit_Inline_Message_Live_Location()
        {
            await _fixture.SendTestInstructionsAsync("Click on location message's button to edit the location");

            Update cqUpdate = await _fixture.UpdateReceiver
                              .GetCallbackQueryUpdateAsync(data : _classFixture.CallbackQueryData);

            Location beijing = new Location {
                Latitude = 39.9042f, Longitude = 116.4074f
            };

            await BotClient.EditMessageLiveLocationAsync(
                inlineMessageId : cqUpdate.CallbackQuery.InlineMessageId,
                latitude : beijing.Latitude,
                longitude : beijing.Longitude,
                replyMarkup : InlineKeyboardMarkup.Empty()
                );

            _classFixture.InlineMessageId = cqUpdate.CallbackQuery.InlineMessageId;
        }
        public async Task <(string text, bool showAlert, string url)> Handle(CallbackQuery data, object context = default, CancellationToken cancellationToken = default)
        {
            var callback = data.Data?.Split(':');

            if (callback?[0] != ID)
            {
                return(null, false, null);
            }

            var player = await myDb.Set <Player>().Get(data.From, cancellationToken);

            switch (callback.Skip(1).FirstOrDefault()?.ToLowerInvariant())
            {
            case Commands.ClearIGN:
                if (player != null)
                {
                    player.Nickname = null;
                    await myDb.SaveChangesAsync(cancellationToken);
                }

                await myBot.EditMessageReplyMarkupAsync(data, InlineKeyboardMarkup.Empty(), cancellationToken);

                return("Your IGN is removed", false, null);

            case Commands.ClearFriendCode:
                if (player != null)
                {
                    player.FriendCode = null;
                    await myDb.SaveChangesAsync(cancellationToken);
                }

                await myBot.EditMessageReplyMarkupAsync(data, InlineKeyboardMarkup.Empty(), cancellationToken);

                return("Your Friend Code is removed", false, null);
            }

            return(null, false, null);
        }
        public static void BotOnInlineQuery(object?sender, CallbackQueryEventArgs callbackQueryEventArgs)
        {
            if (callbackQueryEventArgs.CallbackQuery.Data.StartsWith("set_command"))
            {
                long chatId = callbackQueryEventArgs.CallbackQuery.Message.Chat.Id;

                Bot.Client.EditMessageReplyMarkupAsync(new ChatId(chatId),
                                                       callbackQueryEventArgs.CallbackQuery.Message.MessageId,
                                                       InlineKeyboardMarkup.Empty( ));

                string            service = callbackQueryEventArgs.CallbackQuery.Data.Split('|').Last( );
                SetServicesDialog dialog;
                if (_dialogs.TryGetValue(chatId, out dialog))
                {
                    dialog.SelectedServices.Add(service);
                    dialog.PerformStep(  );
                    if (dialog.IsOver)
                    {
                        _dialogs.Remove(chatId);
                    }
                }
            }
        }
        private async Task ProcessCallback(CommandContext context)
        {
            if (context.Message != null)
            {
                await BotClient.EditMessageReplyMarkupAsync(context.Message.Chat, context.Message.MessageId, InlineKeyboardMarkup.Empty());

                if (context.Parameters == "r")
                {
                    context.RedirectToCommand("/remove", context.SelectedBook.Title);
                }
                else
                {
                    context.RedirectToCommand($"/edit{context.Parameters}");
                }
            }
        }
Beispiel #16
0
        public async override Task ExecuteAsync(CommandContext context)
        {
            if (context.IsCallback && context.Message != null)
            {
                await BotClient.EditMessageReplyMarkupAsync(context.Message.Chat, context.Message.MessageId, InlineKeyboardMarkup.Empty());
            }

            CommandState newState = CommandState.MainMenu;
            string       message  = Localizer["BackMainMenu"];
            var          keyboard = CommandKeyboards.GetMainMenu(Localizer);

            if (context.State == CommandState.EditBookMenu)
            {
                context.SelectedBook = null;
                newState             = CommandState.BookMenu;
                message  = Localizer["BackBookMenu"];
                keyboard = CommandKeyboards.GetBookMenu(Localizer);
            }
            else
            {
                context.SelectedBook      = null;
                context.SelectedBookshelf = null;
            }

            context.ChangeState(newState);
            await BotClient.SendTextMessageAsync(context.Message.Chat, message, replyMarkup : keyboard);

            context.RedirectToCommand("/help");
        }
Beispiel #17
0
        public async override Task ExecuteAsync(CommandContext context)
        {
            if (InputData(context, out string input))
            {
                if (context.IsCallback)
                {
                    await BotClient.EditMessageReplyMarkupAsync(context.Message.Chat, context.Message.MessageId, InlineKeyboardMarkup.Empty());
                }

                string message = Localizer["LanguageError"];
                if (availableLanguages.Any(a => a == input))
                {
                    context.User.Language = input;
                    message = Localizer["LanguageSuccess"];
                }

                await BotClient.SendTextMessageAsync(context.Message.Chat, message);
            }
            else
            {
                List <List <InlineKeyboardButton> > buttons = new List <List <InlineKeyboardButton> >();
                foreach (var language in availableLanguages)
                {
                    var row = new List <InlineKeyboardButton>();
                    row.Add(language);
                    buttons.Add(row);
                }
                InlineKeyboardMarkup markup = new InlineKeyboardMarkup(buttons);

                await BotClient.SendTextMessageAsync(context.Message.Chat, Localizer["LanguageEnter"], replyMarkup : markup);
            }
        }
Beispiel #18
0
        static object AnalyticsInlineKeyboard(int choice)
        {
            var keys = (IReplyMarkup)InlineKeyboardMarkup.Empty();

            switch (choice)
            {
            case 1:
                keys = new InlineKeyboardMarkup(new[]
                {
                    new[]
                    {
                        InlineKeyboardButton.WithCallbackData("Из Instagram", "insta"),
                    },
                    new[]
                    {
                        InlineKeyboardButton.WithCallbackData("Из Вконтакте", "vk"),
                    },
                    new[]
                    {
                        InlineKeyboardButton.WithCallbackData("От Друзей", "friends"),
                    },
                });
                break;

            case 2:
                keys = new InlineKeyboardMarkup(new[]
                {
                    new[]
                    {
                        InlineKeyboardButton.WithCallbackData("Я парень", "boy"),
                    },
                    new[]
                    {
                        InlineKeyboardButton.WithCallbackData("Я девушка", "girl"),
                    },
                });
                break;

            case 3:

                keys = new InlineKeyboardMarkup(new[]
                {
                    new[]
                    {
                        InlineKeyboardButton.WithCallbackData("15-20 лет", "One_years"),
                    },
                    new[]
                    {
                        InlineKeyboardButton.WithCallbackData("20-25 лет", "Two_years"),
                    },
                    new[]
                    {
                        InlineKeyboardButton.WithCallbackData("25-30 лет", "Three_years"),
                    },
                    new[]
                    {
                        InlineKeyboardButton.WithCallbackData("30+ лет", "Four_years"),
                    },
                });

                break;
            }
            return(keys);
        }
        public async Task <int> SendRepliableMessageAsync(string message)
        {
            var sendMessage = await _client.SendTextMessageAsync(new ChatId(_allowedUser), message, replyMarkup : InlineKeyboardMarkup.Empty());

            return(sendMessage.MessageId + 1);
        }
Beispiel #20
0
        public async Task OnContactsAccept(ApplicationContext context, CallbackQuery query, TelegramBotClient client)
        {
            long userId = Convert.ToInt64(query.Data.Split('-')[1]);

            User user = await UserDB.GetUserByChatId(context, query.From.Id);

            User anotherUser = await UserDB.GetUserByChatId(context, userId);

            ContactsBook contact = user.Contacts.FirstOrDefault(c => c.OwnerId == query.From.Id && c.AnotherUserId == userId);

            if (contact != null)
            {
                contact.IsAccepted = true;

                context.ContactsBooks.Update(contact);
                context.SaveChanges();
                await client.EditMessageReplyMarkupAsync(query.From.Id, query.Message.MessageId, InlineKeyboardMarkup.Empty());

                await client.SendTextMessageAsync(query.From.Id, $"Вы дали доступ к своим данным пользователю {anotherUser.FirstName}",
                                                  ParseMode.Markdown);

                await client.SendTextMessageAsync(userId, $"{user.FirstName} потвердил запрос на данные",
                                                  ParseMode.Markdown);
            }
        }
Beispiel #21
0
        static public object ComputerPartsInlineKeyboard()
        {
            var keys = (IReplyMarkup)InlineKeyboardMarkup.Empty();

            DbWorking.RecordingClickKeyboard(productName);

            if (productName == "Видеокарта" || productName == "Процессор" || productName == "Материнская плата")
            {
                keys = new InlineKeyboardMarkup(new[]
                {
                    new[]
                    {
                        InlineKeyboardButton.WithCallbackData("🧾 Список товаров", "view"),
                    },
                    new[]
                    {
                        InlineKeyboardButton.WithCallbackData("💰 Цена", "price"),
                    },
                    new[]
                    {
                        InlineKeyboardButton.WithCallbackData("👔 Производитель", "producer"),
                    },
                    new[]
                    {
                        InlineKeyboardButton.WithCallbackData("❌ Закрыть", "test"),
                    },
                });
            }
            else if (productName == "Дисковый накопитель")
            {
                keys = new InlineKeyboardMarkup(new[]
                {
                    new[]
                    {
                        InlineKeyboardButton.WithCallbackData("🧾 Список товаров", "view"),
                    },
                    new[]
                    {
                        InlineKeyboardButton.WithCallbackData("💰 Цена", "price"),
                    },
                    new[]
                    {
                        InlineKeyboardButton.WithCallbackData("🧰 Виды", "producer"),
                    },
                    new[]
                    {
                        InlineKeyboardButton.WithCallbackData("❌ Закрыть", "test"),
                    },
                });
            }
            else
            {
                keys = new InlineKeyboardMarkup(new[]
                {
                    new[]
                    {
                        InlineKeyboardButton.WithCallbackData("🧾 Список товаров", "view"),
                    },
                    new[]
                    {
                        InlineKeyboardButton.WithCallbackData("💰 Цена", "price"),
                    },
                    new[]
                    {
                        InlineKeyboardButton.WithCallbackData("❌ Закрыть", "test"),
                    },
                });
            }
            return(keys);
        }
Beispiel #22
0
        public async Task OnContactsDecline(ApplicationContext context, CallbackQuery query, TelegramBotClient client)
        {
            long userId = Convert.ToInt64(query.Data.Split('-')[1]);

            User user = await UserDB.GetUserByChatId(context, query.From.Id);

            User anotherUser = await UserDB.GetUserByChatId(context, userId);

            await client.EditMessageReplyMarkupAsync(query.From.Id, query.Message.MessageId, InlineKeyboardMarkup.Empty());

            await client.SendTextMessageAsync(query.From.Id, $"Вы отказали в доступе к контакту",
                                              ParseMode.Markdown);

            await client.SendTextMessageAsync(userId, $"{user.FirstName} отменил запрос на данные",
                                              ParseMode.Markdown);
        }
Beispiel #23
0
    public async Task <InlineKeyboardMarkup> GetButtonMarkup(
        long chatId,
        int page = 0,
        int take = 5
        )
    {
        var buttonMarkup = InlineKeyboardMarkup.Empty();
        var rssSettings  = await GetRssSettingsAsync(chatId);

        var filtered = rssSettings.Skip(page * take).Take(take);

        var prev = page - take;
        var next = page + take;

        var buttons = new List <InlineKeyboardButton[]>();

        if (filtered.Any())
        {
            buttons.Add(
                new InlineKeyboardButton[]
            {
                InlineKeyboardButton.WithCallbackData("🚫 Stop All", $"rssctl stop-all"),
                InlineKeyboardButton.WithCallbackData("✅ Start All", $"rssctl start-all"),
            }
                );

            filtered.ForEach(
                (
                    rssSetting,
                    index
                ) => {
                var btnCtl = new List <InlineKeyboardButton>()
                {
                    InlineKeyboardButton.WithCallbackData("❌ Delete", $"rssctl delete {rssSetting.Id}"),
                };

                if (rssSetting.IsEnabled)
                {
                    btnCtl.Add(InlineKeyboardButton.WithCallbackData("✅ Started", $"rssctl stop {rssSetting.Id}"));
                }
                else
                {
                    btnCtl.Add(InlineKeyboardButton.WithCallbackData("🚫 Stopped", $"rssctl start {rssSetting.Id}"));
                }

                // if (rssSetting.UrlFeed.IsGithubReleaseUrl())
                //     if (rssSetting.IncludeAttachment)
                //         btnCtl.Add(InlineKeyboardButton.WithCallbackData("✅ Attachment", $"rssctl attachment-off {rssSetting.Id}"));
                //     else
                //         btnCtl.Add(InlineKeyboardButton.WithCallbackData("❌ Attachment", $"rssctl attachment-on {rssSetting.Id}"));

                buttons.AddRange(
                    new InlineKeyboardButton[][]
                {
                    new InlineKeyboardButton[]
                    {
                        InlineKeyboardButton.WithUrl($"{index + 1}. {rssSetting.UrlFeed}", rssSetting.UrlFeed),
                    },
                    btnCtl.ToArray()
                }
                    );
            }
                );

            buttons.Add(
                new InlineKeyboardButton[]
            {
                InlineKeyboardButton.WithCallbackData("Prev", $"rssctl navigate-page {page - 1}"),
                InlineKeyboardButton.WithCallbackData("Next", $"rssctl navigate-page {page + 1}"),
            }
                );

            buttonMarkup = new InlineKeyboardMarkup(buttons);
        }

        return(buttonMarkup);
    }
        public async Task <(string text, bool showAlert, string url)> Handle(CallbackQuery data, object context = default, CancellationToken cancellationToken = default)
        {
            var callback = data.Data?.Split(':');

            if (callback?[0] != ID)
            {
                return(null, false, null);
            }

            var host   = data.From;
            var player = await myDB.Set <Player>().Get(host, cancellationToken);

            var command          = callback.Skip(1).FirstOrDefault();
            var commandParameter = callback.Skip(2).FirstOrDefault();

            switch (command)
            {
            case Commands.SendCodeId:
            case Commands.AutoApproveId:
            case Commands.ApproveSettingsId when bool.TryParse(commandParameter, out var autoApprove) && autoApprove:
                if (player?.FriendCode == null)
                {
                    await myFriendshipService.SetupFriendCode(myBot, host, StringSegment.Empty, cancellationToken);

                    return("Please, specify your Friend Code first", true, null);
                }

                break;
            }


            switch (command)
            {
            case Commands.SendCodeId
                when long.TryParse(commandParameter, out var userId) &&
                long.TryParse(callback.Skip(3).FirstOrDefault(), out var botId):
                try
                {
                    if (!myBots.TryGetValue(botId, out var bot))
                    {
                        bot = myBot;
                    }
                    await myFriendshipService.SendCode(bot, new User { Id = userId }, host, player, cancellationToken);

                    await myBot.EditMessageReplyMarkupAsync(data, InlineKeyboardMarkup.Empty(), cancellationToken);

                    return("Friend Code sent", false, null);
                }
                catch (ApiRequestException apiEx) when(apiEx.ErrorCode == 403)
                {
                    return("User blocked personal messages for the bot.\r\nSend him/her code by yourself.", true, null);
                }

            case Commands.AskCodeId
                when long.TryParse(commandParameter, out var userId) &&
                long.TryParse(callback.Skip(3).FirstOrDefault(), out var botId):
                try
                {
                    if (!myBots.TryGetValue(botId, out var bot))
                    {
                        bot = myBot;
                    }
                    await myFriendshipService.AskCode(host, myBot, new User { Id = userId }, bot, player, cancellationToken);

                    await myBot.EditMessageReplyMarkupAsync(data, InlineKeyboardMarkup.Empty(), cancellationToken);

                    return("Friend Code asked", false, null);
                }
                catch (ApiRequestException apiEx) when(apiEx.ErrorCode == 403)
                {
                    return("User blocked personal messages for the bot.\r\nAsk him/her for the code by yourself.", true, null);
                }

            case Commands.ApproveId
                when int.TryParse(commandParameter, out var userId):

                await myFriendshipService.ApproveFriendship(host, new User { Id = userId }, cancellationToken);

                await myBot.EditMessageReplyMarkupAsync(data, InlineKeyboardMarkup.Empty(), cancellationToken);

                return("He/She marked as already Friend.", false, null);

            case Commands.AutoApproveId
                when int.TryParse(commandParameter, out var pollId):

                var poll = await myDB
                           .Set <Poll>()
                           .Where(_ => _.Id == pollId)
                           .IncludeRelatedData()
                           .FirstOrDefaultAsync(cancellationToken);

                if (poll == null)
                {
                    return("Poll is publishing. Try later.", true, null);
                }

                var hostVote = poll.Votes.FirstOrDefault(_ => _.UserId == host.Id);
                if (hostVote == null)
                {
                    return("Poll is publishing. Try later.", true, null);
                }

                hostVote.Team |= VoteEnum.AutoApproveFriend;

                // approve already awaiting requests
                foreach (var friendship in await myDB.Set <Friendship>()
                         .Where(f => f.PollId == pollId && (f.Id == host.Id || f.FriendId == host.Id)).ToListAsync(cancellationToken))
                {
                    friendship.Type = FriendshipType.Approved;
                    if (poll.Votes.SingleOrDefault(v => (v.UserId == friendship.Id || v.UserId == friendship.FriendId) && v.UserId != host.Id) is { } vote)
                    {
                        try
                        {
                            if (vote.BotId is not {
                            } botId || !myBots.TryGetValue(botId, out var bot))
                            {
                                bot = myBot;
                            }
                            await myFriendshipService.SendCode(bot, vote.User, host, player, cancellationToken);
                        }
                        catch (ApiRequestException apiEx) when(apiEx.ErrorCode == 403)
                        {
                            // personal messages banned for host - propose user to ask for FC manually
                        }
                    }
                }
                await myDB.SaveChangesAsync(cancellationToken);

                await myBot.EditMessageReplyMarkupAsync(data, InlineKeyboardMarkup.Empty(), cancellationToken);

                return($"All invitees of `{poll.Title}` will be automatically approved.", false, null);

            case Commands.ApproveSettingsId:
                if (player == null)
                {
                    player = new Player
                    {
                        UserId = host.Id
                    };
                    myDB.Add(player);
                }
                if (bool.TryParse(commandParameter, out var autoApprove))
                {
                    player.AutoApproveFriendship = autoApprove;
                }
                else
                {
                    player.AutoApproveFriendship = null;
                }

                await myDB.SaveChangesAsync(cancellationToken);

                await myBot.EditMessageReplyMarkupAsync(data, FriendshipCommandHandler.GetInlineKeyboardMarkup(player), cancellationToken);

                return("Friendship settings modified", false, null);
            }

            return(null, false, null);
        }
        public override async Task ProcessAsync(Message message, params string[] arguments)
        {
            string symbolId = arguments.First().TrimStart('/');
            Market market   = _mindTricksService.GetMarket(symbolId);

            Enum.TryParse(arguments.Skip(1).FirstOrDefault(), out DisplayType displayType);

            var currentInlineKeyboard = new InlineKeyboardMarkup(new[]
            {
                new []         // first row
                {
                    InlineKeyboardButton.WithCallbackData("Same Time Last Month", $"/{symbolId} STLM"),
                    InlineKeyboardButton.WithCallbackData("Same Time Last Year", $"/{symbolId} STLY")
                },
                new []         //second row
                {
                    InlineKeyboardButton.WithCallbackData("Details", $"/{symbolId} Details"),
                }
            });
            var detailsInlineKeyboard = new InlineKeyboardMarkup(new[]
            {
                new []         // first row
                {
                    InlineKeyboardButton.WithCallbackData("Add to favourites", $"/favourites {symbolId}")
                }
            });
            IReplyMarkup replyMarkup;

            if (market != null && displayType == DisplayType.Current)
            {
                replyMarkup = currentInlineKeyboard;
            }
            else if (market != null && displayType == DisplayType.Details)
            {
                replyMarkup = detailsInlineKeyboard;
            }
            else
            {
                replyMarkup = InlineKeyboardMarkup.Empty();
            }

            string replyText = "";

            if (market == null)
            {
                replyText = "Symbol not found";
            }
            else if (displayType == DisplayType.Details)
            {
                replyText = $"{market.ToLongDisplayValue()}";
            }
            else
            {
                replyText = $"/{market.NormalizedSymbol} "
                            + (displayType == DisplayType.STLY
                        ? "<strong>Same time last year</strong>"
                        : displayType == DisplayType.STLM
                            ? "<strong>Same time last month</strong>"
                            : "")
                            + "\n"
                            + FormatPrice(displayType == DisplayType.STLY
                        ? market.STLY
                        : displayType == DisplayType.STLM
                            ? market.STLM
                            : market.LastPrice);
            }

            await _botClient.SendTextMessageAsync(
                message.Chat.Id,
                replyText,
                ParseMode.Html, replyMarkup : replyMarkup);
        }