update bot struct

pull/271/head
Sergey Ryazanov 6 years ago
parent b33efeebc7
commit 67c024dc85
  1. 8
      bot.go
  2. 1
      configs.go

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

@ -11,7 +11,6 @@ import (
const ( const (
// APIEndpoint is the endpoint for all API methods, // APIEndpoint is the endpoint for all API methods,
// with formatting for Sprintf. // with formatting for Sprintf.
APIEndpoint = "https://api.telegram.org/bot%s/%s"
// FileEndpoint is the endpoint for downloading a file from Telegram. // FileEndpoint is the endpoint for downloading a file from Telegram.
FileEndpoint = "https://api.telegram.org/file/bot%s/%s" FileEndpoint = "https://api.telegram.org/file/bot%s/%s"
) )