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
Publish telemt-bot Docker image / build-and-push (push) Successful in 53s
This commit is contained in:
@@ -350,9 +350,20 @@ func (b *bot) handleCreateUser(ctx context.Context, chatID int64, text string) e
|
|||||||
return b.sendMessage(ctx, chatID, "Ошибка создания пользователя: "+err.Error())
|
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)
|
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
|
msg = msg + "\n\nСсылки:\n" + linksText
|
||||||
|
} else {
|
||||||
|
msg = msg + "\n\nСсылки не вернулись из API."
|
||||||
}
|
}
|
||||||
return b.sendMessage(ctx, chatID, msg)
|
return b.sendMessage(ctx, chatID, msg)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user