|
|
@ -36,7 +36,7 @@ type BotAPI struct { |
|
|
|
//
|
|
|
|
//
|
|
|
|
// 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) (*BotAPI, error) { |
|
|
|
return NewBotAPIWithClient(token, &http.Client{}) |
|
|
|
return CreateNewBotAPI(token, &http.Client{}, false) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// NewBotAPIWithClient creates a new BotAPI instance
|
|
|
|
// NewBotAPIWithClient creates a new BotAPI instance
|
|
|
@ -44,12 +44,28 @@ func NewBotAPI(token string) (*BotAPI, error) { |
|
|
|
//
|
|
|
|
//
|
|
|
|
// 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, client *http.Client) (*BotAPI, error) { |
|
|
|
|
|
|
|
return CreateNewBotAPI(token, client, false) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// NewBotAPIWithDebug creates a new BotAPI instance
|
|
|
|
|
|
|
|
// and enables debug by default.
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// It requires a token, provided by @BotFather on Telegram.
|
|
|
|
|
|
|
|
func NewBotAPIWithDebug(token string) (*BotAPI, error) { |
|
|
|
|
|
|
|
return CreateNewBotAPI(token, &http.Client{}, true) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CreateNewBotAPI creates a new BotAPI instance
|
|
|
|
|
|
|
|
// and allows you to pass all additional customization that you might need.
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// It requires a token, provided by @BotFather on Telegram.
|
|
|
|
|
|
|
|
func CreateNewBotAPI(token string, client *http.Client, debug bool) (*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{}), |
|
|
|
|
|
|
|
Debug: debug, |
|
|
|
apiEndpoint: APIEndpoint, |
|
|
|
apiEndpoint: APIEndpoint, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|