We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 637019c commit 2dc2c2eCopy full SHA for 2dc2c2e
src/tgbot/bot.go
@@ -2,6 +2,7 @@ package tgbot
2
3
import (
4
"log"
5
+ "os"
6
"time"
7
8
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
@@ -17,7 +18,14 @@ type Bot struct {
17
18
}
19
20
func New(token string, editInterval time.Duration) (*Bot, error) {
- api, err := tgbotapi.NewBotAPI(token)
21
+ var api *tgbotapi.BotAPI
22
+ var err error
23
+ apiEndpoint, exist := os.LookupEnv("TELEGRAM_API_ENDPOINT")
24
+ if exist && apiEndpoint != "" {
25
+ api, err = tgbotapi.NewBotAPIWithAPIEndpoint(token, apiEndpoint)
26
+ } else {
27
+ api, err = tgbotapi.NewBotAPI(token)
28
+ }
29
if err != nil {
30
return nil, err
31
0 commit comments