public async Task <bool?> Handle(InlineQuery data, object context = default, CancellationToken cancellationToken = default) { var results = new List <InlineQueryResult>(); var query = data.Query; string encodedId = null; if (Regex.Match(query, PATTERN) is { Success : true } match) { encodedId = match.Groups["Id"].Value; query = query.Remove(match.Index, match.Length); } query = query.Trim(); var matchedZones = myDateTimeZoneProvider.Ids.Where(id => { // check tz id if (id.Contains(query, StringComparison.OrdinalIgnoreCase)) { return(true); } // check Region name return(myTimeZoneService.TryGetRegion(id, out var region) && ( region.EnglishName.Contains(query, StringComparison.OrdinalIgnoreCase) || region.NativeName.Contains(query, StringComparison.OrdinalIgnoreCase))); }).ToList(); InlineKeyboardMarkup replyMarkup = null; if (myTimeZoneNotifyService.DecodeId(encodedId, out var chatId, out var messageId)) { (_, replyMarkup) = await myTimeZoneNotifyService.GetSettingsMessage(new Chat { Id = chatId, Type = ChatType.Sender }, messageId, cancellationToken); } var instant = myClock.GetCurrentInstant(); int.TryParse(data.Offset, out var offset); for (var index = offset; index < matchedZones.Count && index < offset + PAGE_SIZE; index++) { var id = matchedZones[index]; if (myDateTimeZoneProvider.GetZoneOrNull(id) is { } timeZone) { var title = $"{timeZone.Id} ({timeZone.GetUtcOffset(instant)})"; var builder = new TextBuilder() .Append($"{title}\x00A0") // trailing space is necessary to allow edit it further to the same message .NewLine(); string countryString = null; if (myTimeZoneService.TryGetRegion(timeZone.Id, out var country)) { countryString = $"{country.EnglishName} {country.NativeName}"; builder.Sanitize(countryString).NewLine(); } results.Add(new InlineQueryResultArticle($"{PREFIX}:{encodedId}:{timeZone.Id}", title, builder.ToTextMessageContent()) { Description = countryString, ReplyMarkup = replyMarkup }); } } string nextOffset = default; if (results.Count == 0 && offset == 0) { results.Add(new InlineQueryResultArticle("NothingFound", "Nothing found", new TextBuilder($"Nothing found by request ").Code(builder => builder.Sanitize(query)).ToTextMessageContent()) { Description = $"Request {query}", ThumbUrl = myUrlHelper.AssetsContent(@"static_assets/png/btn_close_normal.png").AbsoluteUri }); } else { nextOffset = (offset + PAGE_SIZE).ToString(); } await myBot.AnswerInlineQueryWithValidationAsync(data.Id, results, nextOffset : nextOffset, cacheTime : 0, isPersonal : true, cancellationToken : cancellationToken); return(true); }