From 09ef6cde1a0767889cfbb5908a99032709f468ed Mon Sep 17 00:00:00 2001 From: AshokShau <114943948+AshokShau@users.noreply.github.com> Date: Fri, 18 Oct 2024 18:40:44 +0530 Subject: [PATCH] Done: Vercel support --- .github/README.md | 16 +++++++++++++++- Telegram/config/config.go | 4 ++-- Telegram/modules/inline.go | 7 +------ sample.env | 2 +- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.github/README.md b/.github/README.md index 25040aa..818d489 100644 --- a/.github/README.md +++ b/.github/README.md @@ -92,7 +92,20 @@ Contributions are welcome! Here's how you can help: Please ensure your code follows the project's coding standards and includes appropriate tests. - + +
+

Deploy to Vercel

+
    +
  1. Fork this repository šŸ“
  2. +
  3. Login your Vercel account
  4. +
  5. Go to your Add New Project
  6. +
  7. Choose the repository you forked
  8. +
  9. Configure your Environment Variables: OWNER_ID & VERCEL=1
  10. +
  11. Tap on Deploy
  12. +
  13. Open and Connect Your Bot
  14. +
+
+ ## License This project is licensed under the MIT Licenseā€”see the [LICENSE](/LICENSE) file for details. @@ -107,3 +120,4 @@ This project is licensed under the MIT Licenseā€”see the [LICENSE](/LICENSE) fil - **[Ashok Shau](https://github.com/AshokShau)**: For creating and maintaining this [project](https://github.com/AshokShau/BotApiDocs), which provides a solid foundation for building Telegram bots. - **[PaulSonOfLars](https://github.com/PaulSonOfLars)**: For the invaluable [GoTgBot](https://github.com/PaulSonOfLars/gotgbot) library, which simplifies Telegram bot development in Go, and for the [API specification](https://github.com/PaulSonOfLars/telegram-bot-api-spec/raw/main/api.json) that serves as a reference for bot methods and types. + diff --git a/Telegram/config/config.go b/Telegram/config/config.go index babe81f..d283577 100644 --- a/Telegram/config/config.go +++ b/Telegram/config/config.go @@ -12,13 +12,13 @@ var ( OwnerId int64 WebhookUrl string Port string - VERCEL string + Vercel string ) func init() { Token = os.Getenv("TOKEN") OwnerId = toInt64(os.Getenv("OWNER_ID")) - VERCEL = os.Getenv("VERCEL") + Vercel = os.Getenv("Vercel") WebhookUrl = os.Getenv("WEBHOOK_URL") Port = os.Getenv("PORT") } diff --git a/Telegram/modules/inline.go b/Telegram/modules/inline.go index ee758b5..b813c57 100644 --- a/Telegram/modules/inline.go +++ b/Telegram/modules/inline.go @@ -53,8 +53,7 @@ type Field struct { // isVercel checks if the application is running on Vercel. func isVercel() bool { - //return config.VERCEL == "1" - return true + return config.Vercel == "1" } // fetchAPI fetches the API documentation from a remote source and updates the apiCache. @@ -85,8 +84,6 @@ func fetchAPI() error { } func getAPICache() (map[string]Method, map[string]Type, error) { - log.Println(config.VERCEL) - log.Print("isVercel: ", isVercel()) if isVercel() { // Fetch the API on Vercel if err := fetchAPI(); err != nil { @@ -139,8 +136,6 @@ func inlineQueryHandler(bot *gotgbot.Bot, ctx *ext.Context) error { } results := searchAPI(query, methods, types) - log.Println("Search results for query:", results) - if len(results) == 0 { return sendNoResultsResponse(bot, ctx, query) } diff --git a/sample.env b/sample.env index d5c3450..b58842e 100644 --- a/sample.env +++ b/sample.env @@ -1,3 +1,3 @@ TOKEN= OWNER_ID= -VERCEL=1 +VERCEL=0# if on Vercel - set to 1