Added max connections configuration option to SetWebHook
parent
80bdd621f7
commit
833e457376
7
bot.go
7
bot.go
|
@ -409,15 +409,22 @@ func (bot *BotAPI) RemoveWebhook() (APIResponse, error) {
|
|||
// If you do not have a legitimate TLS certificate, you need to include
|
||||
// your self signed certificate with the config.
|
||||
func (bot *BotAPI) SetWebhook(config WebhookConfig) (APIResponse, error) {
|
||||
|
||||
if config.Certificate == nil {
|
||||
v := url.Values{}
|
||||
v.Add("url", config.URL.String())
|
||||
if config.MaxConnections != 0 {
|
||||
v.Add("max_connections", strconv.Itoa(config.MaxConnections))
|
||||
}
|
||||
|
||||
return bot.MakeRequest("setWebhook", v)
|
||||
}
|
||||
|
||||
params := make(map[string]string)
|
||||
params["url"] = config.URL.String()
|
||||
if config.MaxConnections != 0 {
|
||||
params["max_connections"] = strconv.Itoa(config.MaxConnections)
|
||||
}
|
||||
|
||||
resp, err := bot.UploadFile("setWebhook", params, "certificate", config.Certificate)
|
||||
if err != nil {
|
||||
|
|
|
@ -770,6 +770,7 @@ type UpdateConfig struct {
|
|||
type WebhookConfig struct {
|
||||
URL *url.URL
|
||||
Certificate interface{}
|
||||
MaxConnections int
|
||||
}
|
||||
|
||||
// FileBytes contains information about a set of bytes to upload
|
||||
|
|
15
helpers.go
15
helpers.go
|
@ -318,6 +318,21 @@ func NewWebhookWithCert(link string, file interface{}) WebhookConfig {
|
|||
}
|
||||
}
|
||||
|
||||
// NewWebhookWithCert creates a new webhook with a certificate and max_connections.
|
||||
//
|
||||
// link is the url you wish to get webhooks,
|
||||
// file contains a string to a file, FileReader, or FileBytes.
|
||||
// maxConnections defines maximum number of connections from telegram to your server
|
||||
func NewWebhookWithCertAndMaxConnections(link string, file interface{}, maxConnections int) WebhookConfig {
|
||||
u, _ := url.Parse(link)
|
||||
|
||||
return WebhookConfig{
|
||||
URL: u,
|
||||
Certificate: file,
|
||||
MaxConnections: maxConnections,
|
||||
}
|
||||
}
|
||||
|
||||
// NewInlineQueryResultArticle creates a new inline query article.
|
||||
func NewInlineQueryResultArticle(id, title, messageText string) InlineQueryResultArticle {
|
||||
return InlineQueryResultArticle{
|
||||
|
|
Loading…
Reference in New Issue