private static async Task <InlineQueryExecutionResult> OnInlineQueryPingAsync(this TelegramService telegramService)
    {
        var inlineResult = new InlineQueryExecutionResult();

        await telegramService.AnswerInlineQueryAsync(
            new List <InlineQueryResult>()
        {
            new InlineQueryResultArticle(
                "ping-result",
                "Pong!",
                new InputTextMessageContent("Pong!")
                )
        }
            );

        inlineResult.IsSuccess = true;

        return(inlineResult);
    }
    private static async Task <InlineQueryExecutionResult> OnInlineQueryGuideAsync(this TelegramService telegramService)
    {
        var learnMore    = "https://docs.zizibot.winten.my.id/features/inline-query";
        var inlineResult = new InlineQueryExecutionResult();

        var learnMoreContent = $"Silakan pelajari selengkapnya" +
                               $"\n{learnMore}" +
                               $"\n\nAtau tekan salah satu tombol dibawah ini";

        var replyMarkup = new InlineKeyboardMarkup(
            new[]
        {
            new[]
            {
                InlineKeyboardButton.WithSwitchInlineQueryCurrentChat("Ping", $"ping")
            },
            new[]
            {
                InlineKeyboardButton.WithSwitchInlineQueryCurrentChat("Buat pesan dengan tombol", $"message")
            },
            new[]
            {
                InlineKeyboardButton.WithSwitchInlineQueryCurrentChat("Cari subtitle", "subscene ")
            },
            new[]
            {
                InlineKeyboardButton.WithSwitchInlineQueryCurrentChat("Cari UUP dump", "uup ")
            },
        }
            );

        await telegramService.AnswerInlineQueryAsync(
            new List <InlineQueryResult>()
        {
            new InlineQueryResultArticle(
                id: "guide-1",
                title: "Bagaimana cara menggunakannya?",
                inputMessageContent: new InputTextMessageContent(learnMoreContent)
            {
                DisableWebPagePreview = true
            }
                )
            {
                ReplyMarkup = replyMarkup
            },
            new InlineQueryResultArticle(
                id: "guide-2",
                title: "Cobalah ketikkan 'ping'",
                inputMessageContent: new InputTextMessageContent(learnMoreContent)
            {
                DisableWebPagePreview = true
            }
                )
            {
                ReplyMarkup = replyMarkup
            }
        }
            );

        inlineResult.IsSuccess = true;

        return(inlineResult);
    }
    private static async Task <InlineQueryExecutionResult> OnInlineQuerySearchUupAsync(this TelegramService telegramService)
    {
        var inlineQueryExecution = new InlineQueryExecutionResult();
        var uupService           = telegramService.GetRequiredService <UupDumpService>();
        var query1     = telegramService.GetInlineQueryAt <string>(1);
        var query2     = telegramService.GetInlineQueryAt <string>(2);
        var queryValue = telegramService.InlineQueryValue;
        var builds     = await uupService.GetUpdatesAsync(queryValue);

        var inlineQueryResults = builds.Response.Builds.Select(
            build => {
            var title = build.BuildNumber + " - " + build.Arch.ToString().ToUpper();

            var downloadLink = build.Arch == Arch.Arm64
                    ? $"https://uupdump.net/download.php?id={build.Uuid}&pack=en-us&edition=core;professional"
                    : $"https://uupdump.net/download.php?id={build.Uuid}&pack=en-us&edition=core;coren;professional;professionaln";

            var htmlDescription = HtmlMessage.Empty
                                  .TextBr(build.Created.ToString("yyyy-MM-dd HH:mm:ss tt zz"))
                                  .TextBr(build.Title);

            var htmlContent = HtmlMessage.Empty
                              .Bold("Title: ").CodeBr(build.Title)
                              .Bold("Version: ").CodeBr(build.BuildNumber)
                              .Bold("Date: ").CodeBr(build.Created.ToString("yyyy-MM-dd HH:mm:ss tt zz"))
                              .Bold("Arch: ").CodeBr(build.Arch.ToString().ToUpper());

            var result = new InlineQueryResultArticle(
                id: build.Uuid,
                title: title,
                inputMessageContent: new InputTextMessageContent(htmlContent.ToString())
            {
                ParseMode             = ParseMode.Html,
                DisableWebPagePreview = true
            }
                )
            {
                Description = htmlDescription.ToString(),
                ReplyMarkup = new InlineKeyboardMarkup(
                    new[]
                {
                    new[]
                    {
                        InlineKeyboardButton.WithUrl("Unduh", downloadLink)
                    },
                    new[]
                    {
                        InlineKeyboardButton.WithSwitchInlineQueryCurrentChat("Pencarian lanjut", $"uup {queryValue} "),
                        InlineKeyboardButton.WithSwitchInlineQueryCurrentChat("Ulang pencarian", $"uup "),
                    }
                }
                    )
            };

            return(result);
        }
            );

        await telegramService.AnswerInlineQueryAsync(inlineQueryResults);

        return(inlineQueryExecution);
    }
    private static async Task <InlineQueryExecutionResult> OnInlineQuerySubsceneDownloadAsync(this TelegramService telegramService)
    {
        var executionResult = new InlineQueryExecutionResult();
        var queryCmd        = telegramService.GetInlineQueryAt <string>(0);
        var query1          = telegramService.GetInlineQueryAt <string>(1);
        var query2          = telegramService.GetInlineQueryAt <string>(2);
        var queryValue      = telegramService.InlineQueryValue;

        Log.Information("Starting find Subtitle file with title: '{QueryValue}'", query1);

        var subsceneService = telegramService.GetRequiredService <SubsceneService>();
        var searchBySlug    = await subsceneService.GetOrFeedSubtitleBySlug(query1);

        Log.Information(
            "Found about {AllCount} subtitle by slug: '{QueryValue}'",
            searchBySlug.Count,
            query1
            );

        var filteredSearch = searchBySlug.Where(
            element => {
            if (query2.IsNullOrEmpty())
            {
                return(true);
            }

            return(element.Language.Contains(query2, StringComparison.CurrentCultureIgnoreCase) ||
                   element.MovieName.Contains(query2, StringComparison.CurrentCultureIgnoreCase) ||
                   element.Owner.Contains(query2, StringComparison.CurrentCultureIgnoreCase));
        }
            ).ToList();

        Log.Information(
            "Found about {FilteredCount} of {AllCount} subtitle with title: '{QueryValue}'",
            filteredSearch.Count,
            searchBySlug.Count,
            query2
            );

        if (filteredSearch.Count == 0)
        {
            await telegramService.AnswerInlineQueryAsync(
                new List <InlineQueryResult>()
            {
                new InlineQueryResultArticle(
                    id: StringUtil.NewGuid(),
                    title: "Tidak di temukan hasil, silakan cari bahasa/judul yang lain",
                    inputMessageContent: new InputTextMessageContent("Tekan tombol dibawah ini untuk memulai pencarian")
                    )
                {
                    ReplyMarkup = new InlineKeyboardMarkup(
                        new[]
                    {
                        InlineKeyboardButton.WithSwitchInlineQueryCurrentChat("Pencarian baru", "subscene ")
                    }
                        )
                }
            }
                );

            executionResult.IsSuccess = false;

            return(executionResult);
        }

        var urlStart = await telegramService.GetUrlStart("");

        var result = filteredSearch.Select(
            element => {
            var documentId  = element.ID;
            var languageSub = element.Language;
            var movieName   = element.MovieName;
            var movieUrl    = element.MovieUrl;
            var ownerSub    = element.Owner;
            var slug        = element.MovieUrl?.Split("/").Skip(2).JoinStr("/");
            var subtitleUrl = "https://subscene.com" + movieUrl;

            Log.Debug(
                "Appending Movie with slug: '{0}' => {1}",
                slug,
                movieName
                );

            var titleResult = $"{languageSub} | {ownerSub}";

            var content = HtmlMessage.Empty
                          .Bold("Nama/Judul: ").CodeBr(movieName)
                          .Bold("Bahasa: ").CodeBr(languageSub)
                          .Bold("Pemilik: ").Text(element.Owner);

            // var startDownloadUrl = urlStart + "start=sub-dl_" + slug.Replace("/", "=");
            var startDownloadUrl = urlStart + "start=sub-dl_" + documentId;

            var article = new InlineQueryResultArticle(
                id: documentId,
                title: titleResult,
                inputMessageContent: new InputTextMessageContent(content.ToString())
            {
                ParseMode             = ParseMode.Html,
                DisableWebPagePreview = true
            }
                )
            {
                Description = movieName,
                ReplyMarkup = new InlineKeyboardMarkup(
                    new[]
                {
                    new[]
                    {
                        InlineKeyboardButton.WithUrl("Tautan subtitle", subtitleUrl)
                    },
                    new[]
                    {
                        InlineKeyboardButton.WithSwitchInlineQueryCurrentChat("Pencarian lanjut", $"subscene-dl {queryValue} "),
                        InlineKeyboardButton.WithSwitchInlineQueryCurrentChat("Ulang pencarian", $"subscene-dl {query1} "),
                    },
                    new[]
                    {
                        InlineKeyboardButton.WithUrl("Unduh subtitle", startDownloadUrl),
                        InlineKeyboardButton.WithSwitchInlineQueryCurrentChat("Pencarian baru", "subscene ")
                    }
                }
                    )
            };

            return(article);
        }
            );

        await telegramService.AnswerInlineQueryAsync(result);

        executionResult.IsSuccess = true;

        return(executionResult);
    }
    private static async Task <InlineQueryExecutionResult> OnInlineQuerySubsceneSearchAsync(this TelegramService telegramService)
    {
        var executionResult = new InlineQueryExecutionResult();
        List <SubsceneMovieSearch> subsceneMovieSearches;

        var queryCmd   = telegramService.InlineQueryCmd;
        var queryValue = telegramService.InlineQueryValue;

        Log.Information("Starting find Subtitle with title: '{QueryValue}'", queryValue);

        var subsceneService = telegramService.GetRequiredService <SubsceneService>();

        if (queryValue.IsNotNullOrEmpty())
        {
            subsceneMovieSearches = await subsceneService.GetOrFeedMovieByTitle(queryValue);

            if (subsceneMovieSearches == null)
            {
                var title = "Tidak di temukan hasil, silakan cari judul yang lain";
                if (queryValue.IsNullOrEmpty())
                {
                    title = "Silakan masukkan judul yang ingin dicari";
                }

                await telegramService.AnswerInlineQueryAsync(
                    new List <InlineQueryResult>()
                {
                    new InlineQueryResultArticle(
                        id: StringUtil.NewGuid(),
                        title: title,
                        inputMessageContent: new InputTextMessageContent("Tekan tombol dibawah ini untuk memulai pencarian")
                        )
                    {
                        ReplyMarkup = new InlineKeyboardMarkup(
                            new[]
                        {
                            InlineKeyboardButton.WithSwitchInlineQueryCurrentChat("Pencarian baru", "subscene ")
                        }
                            )
                    }
                }
                    );

                executionResult.IsSuccess = false;

                return(executionResult);
            }
        }
        else
        {
            subsceneMovieSearches = await subsceneService.GetOrFeedMovieByTitle("");
        }

        Log.Information(
            "Found about {AllCount} title with query: '{QueryValue}'",
            subsceneMovieSearches.Count,
            queryValue
            );

        var inlineQueryResultArticles = subsceneMovieSearches
                                        .OrderByDescending(search => search.CreatedOn)
                                        .Select(
            item => {
            var movieTitle    = item.MovieName;
            var pathName      = item.MovieUrl;
            var subtitleCount = item.SubtitleCount;
            var moviePath     = pathName.Split("/").Take(3).JoinStr("/");
            var slug          = pathName.Split("/").ElementAtOrDefault(2);
            var subsceneUrl   = $"https://subscene.com{moviePath}";

            var titleHtml = HtmlMessage.Empty
                            .Bold("Judul: ").CodeBr(movieTitle)
                            .Bold("Tersedia : ").CodeBr(subtitleCount);

            var article = new InlineQueryResultArticle(
                id: item.ID,
                title: movieTitle,
                inputMessageContent: new InputTextMessageContent(titleHtml.ToString())
            {
                ParseMode             = ParseMode.Html,
                DisableWebPagePreview = true
            }
                )
            {
                Description = $"Tersedia: {subtitleCount}",
                ReplyMarkup = new InlineKeyboardMarkup(
                    new[]
                {
                    new[]
                    {
                        InlineKeyboardButton.WithUrl("Tautan Subscene", subsceneUrl)
                    },
                    new[]
                    {
                        InlineKeyboardButton.WithSwitchInlineQueryCurrentChat("Pencarian lanjut", $"subscene {queryValue} "),
                        InlineKeyboardButton.WithSwitchInlineQueryCurrentChat("Pencarian baru", "subscene ")
                    },
                    new[]
                    {
                        InlineKeyboardButton.WithSwitchInlineQueryCurrentChat("Mulai unduh", $"subscene-dl {slug} "),
                    }
                }
                    )
            };

            return(article);
        }
            );

        // }
        await telegramService.AnswerInlineQueryAsync(inlineQueryResultArticles);

        executionResult.IsSuccess = true;

        return(executionResult);
    }
    private static async Task <InlineQueryExecutionResult> OnInlineQueryMessageAsync(this TelegramService telegramService)
    {
        var executionResult = new InlineQueryExecutionResult();

        var inlineQuery  = telegramService.InlineQuery.Query;
        var parseMessage = inlineQuery
                           .Split(new[] { '(', ')' }, StringSplitOptions.RemoveEmptyEntries)
                           .Where(s => s.Contains('='))
                           .ToDictionary(
            s => s.Split('=')[0],
            s => s.Split('=')[1]
            );

        if (parseMessage.Count == 0)
        {
            var learnMore  = "Pelajari cara membuat Pesan dengan Tombol via InlineQuery";
            var urlArticle = "https://docs.zizibot.winten.my.id/features/inline-query/pesan-dengan-tombol";

            await telegramService.AnswerInlineQueryAsync(
                new List <InlineQueryResult>()
            {
                new InlineQueryResultArticle(
                    "iq-learn-mode",
                    "Pesan dengan tombol via InlineQuery",
                    new InputTextMessageContent(learnMore)
                {
                    DisableWebPagePreview = true
                }
                    )
                {
                    Description = learnMore,
                    ReplyMarkup = new InlineKeyboardMarkup(
                        new[]
                    {
                        new[]
                        {
                            InlineKeyboardButton.WithSwitchInlineQueryCurrentChat("Mulai membuat", "message ")
                        },
                        new[]
                        {
                            InlineKeyboardButton.WithUrl("Pelajari selengkapnya..", urlArticle)
                        }
                    }
                        )
                }
            }
                );

            return(executionResult);
        }

        var caption     = parseMessage.GetValueOrDefault("caption", string.Empty);
        var replyMarkup = parseMessage.GetValueOrDefault("button").ToInlineKeyboardButton().ToButtonMarkup();

        await telegramService.AnswerInlineQueryAsync(
            new List <InlineQueryResult>()
        {
            new InlineQueryResultArticle(
                "123",
                caption,
                new InputTextMessageContent(caption)
                )
            {
                ReplyMarkup = replyMarkup
            }
        }
            );

        executionResult.IsSuccess = true;

        return(executionResult);
    }