|
|
@ -1,12 +1,5 @@ |
|
|
|
package tgbotapi |
|
|
|
package tgbotapi |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
|
|
|
"encoding/json" |
|
|
|
|
|
|
|
"fmt" |
|
|
|
|
|
|
|
"net/url" |
|
|
|
|
|
|
|
"strconv" |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// PassportRequestInfoConfig allows you to request passport info
|
|
|
|
// PassportRequestInfoConfig allows you to request passport info
|
|
|
|
type PassportRequestInfoConfig struct { |
|
|
|
type PassportRequestInfoConfig struct { |
|
|
|
BotID int `json:"bot_id"` |
|
|
|
BotID int `json:"bot_id"` |
|
|
@ -15,22 +8,6 @@ type PassportRequestInfoConfig struct { |
|
|
|
PublicKey string `json:"public_key"` |
|
|
|
PublicKey string `json:"public_key"` |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func LinkToPassportRequest(config PassportRequestInfoConfig) (string, error) { |
|
|
|
|
|
|
|
scope, err := json.Marshal(config.Scope) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
panic("couldn't pack scope") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
tgurl := fmt.Sprintf("tg://resolve?domain=telegrampassport&bot_id=%v&scope=%v&public_key=%v&nonce=%v", |
|
|
|
|
|
|
|
strconv.Itoa(config.BotID), |
|
|
|
|
|
|
|
url.PathEscape(string(scope)), |
|
|
|
|
|
|
|
url.PathEscape(config.PublicKey), |
|
|
|
|
|
|
|
url.PathEscape(config.Nonce), |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
fmt.Println(tgurl) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return tgurl, nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type PassportScopeElement interface { |
|
|
|
type PassportScopeElement interface { |
|
|
|
ScopeType() string |
|
|
|
ScopeType() string |
|
|
|
} |
|
|
|
} |
|
|
|