Skip to content

Commit

Permalink
Done: Vercel support
Browse files Browse the repository at this point in the history
  • Loading branch information
AshokShau committed Oct 18, 2024
1 parent 4fa9e68 commit 09ef6cd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
16 changes: 15 additions & 1 deletion .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
</details>
<section>
<h2>Deploy to Vercel</h2>
<ol>
<li>Fork this repository 🍴</li>
<li>Login your <a href="https://vercel.com/">Vercel</a> account </li>
<li>Go to your <a href="https://vercel.com/new">Add New Project</a></li>
<li>Choose the repository you forked</li>
<li>Configure your Environment Variables: <b>OWNER_ID</b> &amp; <b>VERCEL=1</b></li>
<li>Tap on Deploy</li>
<li><b>Open</b> and Connect Your Bot</li>
</ol>
</section>
## License
This project is licensed under the MIT License—see the [LICENSE](/LICENSE) file for details.
Expand All @@ -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.
4 changes: 2 additions & 2 deletions Telegram/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
7 changes: 1 addition & 6 deletions Telegram/modules/inline.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion sample.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
TOKEN=
OWNER_ID=
VERCEL=1
VERCEL=0# if on Vercel - set to 1

0 comments on commit 09ef6cd

Please sign in to comment.