1
0

Added NewRedirectURL helper

This commit is contained in:
Maxim Lebedev 2018-01-29 14:10:26 +05:00
parent 7d077bbe10
commit 9064ecbab3
No known key found for this signature in database
GPG Key ID: F8978F46FF0FFA4F

View File

@ -138,3 +138,34 @@ func (bot *Bot) NewFileURL(filePath string) *url.URL {
Path: fmt.Sprint("/file/bot", bot.AccessToken, "/", filePath),
}
}
func (bot *Bot) NewRedirectURL(param string, group bool) *url.URL {
if bot == nil {
return nil
}
if bot.Self == nil {
return nil
}
if bot.Self.Username == "" {
return nil
}
link := &url.URL{
Scheme: "https",
Host: "t.me",
Path: bot.Self.Username,
}
q := link.Query()
if group {
q.Add("startgroup", param)
} else {
q.Add("start", param)
}
link.RawQuery = q.Encode()
return link
}