From 8a0710e130f76cfad6625a765e62d29dc404dae1 Mon Sep 17 00:00:00 2001 From: AshokShau <114943948+AshokShau@users.noreply.github.com> Date: Fri, 18 Oct 2024 18:05:05 +0530 Subject: [PATCH] debug and last try --- Telegram/modules/inline.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Telegram/modules/inline.go b/Telegram/modules/inline.go index 19e10ba..fe2088b 100644 --- a/Telegram/modules/inline.go +++ b/Telegram/modules/inline.go @@ -53,11 +53,13 @@ type Field struct { // isVercel checks if the application is running on Vercel. func isVercel() bool { + log.Println(config.VERCEL) return config.VERCEL == "1" } // fetchAPI fetches the API documentation from a remote source and updates the apiCache. func fetchAPI() error { + log.Println("Starting API fetch") client := &http.Client{Timeout: 10 * time.Second} resp, err := client.Get(apiURL) if err != nil { @@ -74,6 +76,8 @@ func fetchAPI() error { return fmt.Errorf("failed to decode API response: %w", err) } + log.Println("Fetched API documentation:", apiDocs) // Log the fetched data + apiCache.Lock() defer apiCache.Unlock() apiCache.Methods = apiDocs.Methods @@ -113,8 +117,9 @@ func getAPICache() (map[string]Method, map[string]Type, error) { // inlineQueryHandler handles inline queries from the bot. func inlineQueryHandler(bot *gotgbot.Bot, ctx *ext.Context) error { query := strings.TrimSpace(ctx.InlineQuery.Query) - parts := strings.Fields(query) + log.Println("Received inline query:", query) + parts := strings.Fields(query) if len(parts) == 0 { return sendEmptyQueryResponse(bot, ctx) } @@ -126,9 +131,12 @@ func inlineQueryHandler(bot *gotgbot.Bot, ctx *ext.Context) error { methods, types, err := getAPICache() if err != nil { - return fmt.Errorf("failed to get API cache: %w", err) + log.Println("Error getting API cache:", err) + return sendNoResultsResponse(bot, ctx, query) } + results := searchAPI(query, methods, types) + log.Println("Search results for query:", results) if len(results) == 0 { return sendNoResultsResponse(bot, ctx, query)