Created
November 2, 2023 18:25
-
-
Save fernand0/6e099c1049f74cbb3151f6f7cc3163e5 to your computer and use it in GitHub Desktop.
Para publicar en bluesky // Publishing in bluesky
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
from atproto import Client, models | |
def main(): | |
client = Client() | |
password = input("Password? ") | |
profile = client.login('fernand0.bsky.social', password) | |
print('Welcome,', profile.display_name) | |
facets = [] | |
text = 'Mi GitHub:' | |
uri = 'http://github.com/fernand0' | |
facets.append( | |
models.AppBskyRichtextFacet.Main( | |
features=[models.AppBskyRichtextFacet.Link(uri=uri)], | |
index=models.AppBskyRichtextFacet.ByteSlice(byte_start=len(text)+1, | |
byte_end=len(text)+len(uri)+1), | |
) | |
) | |
text = f"{text} {uri}" | |
response = client.com.atproto.repo.create_record( | |
models.ComAtprotoRepoCreateRecord.Data( | |
repo=client.me.did, | |
collection=models.ids.AppBskyFeedPost, | |
record=models.AppBskyFeedPost.Main(created_at=client.get_current_time_iso(), text=text, facets=facets), | |
) | |
) | |
print(f"Response: {response}") | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment