Last active
December 16, 2022 14:13
-
-
Save mdowst/a8078c53846ef6bebb34b9c8ea46533d to your computer and use it in GitHub Desktop.
Find Twitter Friends on Mastodon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Uses BluebirdPS to get all of the people you follow on Twitter. | |
Then searches their profile for potential Mastodon usernames. | |
To setup BluebirdPS: https://github.com/thedavecarroll/BluebirdPS | |
#> | |
$TwitterFriends = Get-TwitterFriends | |
# The property fields to search | |
$properties = 'Name','Description' | |
$MastodonFriends = foreach($friend in $TwitterFriends){ | |
foreach($p in $properties){ | |
# Check for username pattern | |
$username = [regex]::Match($friend.$p, '@([^\s]+)@([^\s]+)\.([0-9a-zA-Z\.]+)') | |
if($username.Success){ | |
$friend | Select-Object -Property UserName, Name, @{l='Mastodon';e={$username.Value}} | |
} | |
# Check for link pattern. Convert links to username format | |
$link = [regex]::Match($friend.$p, '([0-9a-zA-Z\.]+)/@([0-9a-zA-Z\.]+)') | |
if($link.Success){ | |
$friend | Select-Object -Property UserName, Name, | |
@{l='Mastodon';e={"$($link.Value.Split('/')[-1])@$($link.Value.Split('/')[0])"}} | |
} | |
} | |
} | |
$MastodonFriends |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment