mirror of
https://github.com/anotherhadi/github-recon.git
synced 2026-10-05 10:58:25 +02:00
42 lines
924 B
Go
42 lines
924 B
Go
package ghrecon
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
type SocialResult struct {
|
|
Provider string `json:"provider"`
|
|
URL string `json:"url"`
|
|
}
|
|
|
|
func (r Recon) Socials(username string) (response []SocialResult) {
|
|
resp, err := FetchGitHubAPI(r.Client, "", "/users/"+username+"/social_accounts")
|
|
if err != nil {
|
|
r.Logger.Error("Failed to fetch socials", "err", err)
|
|
return
|
|
}
|
|
|
|
var socialAccounts []SocialResult
|
|
err = json.Unmarshal(resp, &socialAccounts)
|
|
if err != nil {
|
|
r.Logger.Error("Failed to unmarshal socials", "err", err)
|
|
return
|
|
}
|
|
|
|
if len(socialAccounts) == 0 {
|
|
r.PrintTitle("🐥 Socials")
|
|
r.PrintInfo("INFO", "No commits found")
|
|
} else {
|
|
r.PrintTitle("🐥 Socials")
|
|
for i, account := range socialAccounts {
|
|
r.PrintInfo("Social n°", fmt.Sprintf("%d", i))
|
|
r.PrintInfo("Provider", account.Provider)
|
|
r.PrintInfo("URL", account.URL)
|
|
}
|
|
}
|
|
r.PrintNewline()
|
|
|
|
return socialAccounts
|
|
}
|