<# .SYNOPSIS Get a GitHub user's BlueSky .DESCRIPTION Gets an At Protocol Handle / BlueSky profile link for a GitHub user .EXAMPLE ./GitHubBlueSky StartAutomating #> param([string]$UserName) # Globally cache to avoid repeat request (use script: inside of a function or module) if (-not $global:GitHubProfileCache) { $global:GitHubProfileCache = [Ordered]@{} } # Get the user profile if (-not $global:GitHubProfileCache[$UserName]) { $global:GitHubProfileCache[$UserName] = Invoke-WebRequest "https://github.com/$UserName" } # Skip empty entries if (-not $global:GitHubProfileCache[$UserName]) { return } $blueSkyProfile = ($global:GitHubProfileCache[$UserName].Links -match 'bsky' | Select-Object -ExpandProperty Href) # If we have a bluesky profile if ($blueSkyProfile) { # output an object linking the profiles [PSCustomObject]@{ GitUserName = $UserName GitHubProfile = "https://github.com/$UserName" # and extract the username from the last segment AtUserName = ($blueSkyProfile -as [uri]).Segments[-1] -replace '/' BlueSkyProfile = $blueSkyProfile } } else { # Otherwise, just output the git info [PSCustomObject]@{ GitUserName = $UserName GitHubProfile = "https://github.com/$UserName" } }