all repos — telegram-bot-api @ 1569b35611f745a23526cdb62054f04ccd99c656

Golang bindings for the Telegram Bot API

Merge pull request #313 from AdelyaGarieva/master

Ability to create BotAPI instance directly with new API endpoint
Kirill Zhuharev zhuharev@users.noreply.github.com
Wed, 11 Mar 2020 09:10:48 +0300
commit

1569b35611f745a23526cdb62054f04ccd99c656

parent

aa124ef1e84ecc14654ad242f3cf3bd2b0d5956c

1 files changed, 12 insertions(+), 4 deletions(-)

jump to
M bot.gobot.go

@@ -36,21 +36,29 @@ // NewBotAPI creates a new BotAPI instance.

// // It requires a token, provided by @BotFather on Telegram. func NewBotAPI(token string) (*BotAPI, error) { - return NewBotAPIWithClient(token, &http.Client{}) + return NewBotAPIWithClient(token, APIEndpoint, &http.Client{}) +} + +// NewBotAPIWithAPIEndpoint creates a new BotAPI instance +// and allows you to pass API endpoint. +// +// It requires a token, provided by @BotFather on Telegram and API endpoint. +func NewBotAPIWithAPIEndpoint(token, apiEndpoint string) (*BotAPI, error) { + return NewBotAPIWithClient(token, apiEndpoint, &http.Client{}) } // NewBotAPIWithClient creates a new BotAPI instance // and allows you to pass a http.Client. // -// It requires a token, provided by @BotFather on Telegram. -func NewBotAPIWithClient(token string, client *http.Client) (*BotAPI, error) { +// It requires a token, provided by @BotFather on Telegram and API endpoint. +func NewBotAPIWithClient(token, apiEndpoint string, client *http.Client) (*BotAPI, error) { bot := &BotAPI{ Token: token, Client: client, Buffer: 100, shutdownChannel: make(chan interface{}), - apiEndpoint: APIEndpoint, + apiEndpoint: apiEndpoint, } self, err := bot.GetMe()