Enhance user creation response in main.go to fetch and display user links if not provided by API, with a fallback message for missing links.
Publish telemt-bot Docker image / build-and-push (push) Successful in 53s

This commit is contained in:
Denozordec
2026-03-09 17:43:05 +07:00
parent 9c3879181b
commit 5b5d99f7b1
+12 -1
View File
@@ -350,9 +350,20 @@ func (b *bot) handleCreateUser(ctx context.Context, chatID int64, text string) e
return b.sendMessage(ctx, chatID, "Ошибка создания пользователя: "+err.Error())
}
links := created.User.Links
if len(links.Classic) == 0 && len(links.Secure) == 0 && len(links.TLS) == 0 {
var fetched userInfo
path := "/v1/users/" + url.PathEscape(created.User.Username)
if err := b.callTelemt(ctx, path, &fetched); err == nil {
links = fetched.Links
}
}
msg := fmt.Sprintf("Пользователь создан: %s\nsecret: %s", created.User.Username, created.Secret)
if linksText := formatUserLinks(created.User.Links); linksText != "" {
if linksText := formatUserLinks(links); linksText != "" {
msg = msg + "\n\nСсылки:\n" + linksText
} else {
msg = msg + "\n\nСсылки не вернулись из API."
}
return b.sendMessage(ctx, chatID, msg)
}