-
-
Save samplereality/ed086020d400bb99783fb021069b4789 to your computer and use it in GitHub Desktop.
Moby Deck Python > Bluesky Skeleton
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
# -*- coding: utf-8 -*- | |
from atproto import Client, models | |
# BlueSky Client | |
bs_client = Client() | |
bs_client.login('BLUESKYHANDLE', 'BLUESKYPASSWORD') | |
# Now time to tweet a new line from Moby Dick | |
# Get index line | |
# 'mobyindex.txt' is a text file that contains the line number of the most recently posted passage | |
f = open('/home/pi/Documents/bots/mobydick/mobyindex.txt','r') | |
index = int(f.read().strip()) | |
f.close() | |
# Update index | |
# Bump up the index by 1, so bot knows what the next passage to post is | |
f = open('/home/pi/Documents/bots/mobydick/mobyindex.txt','w') | |
f.write("%d" % (index + 1)) | |
f.close() | |
# Read new line from database of lines and pick out the line with the appropriate index number | |
f = open('/home/pi/Documents/bots/mobydick/mobytweet.txt','r') | |
lines = f.readlines() | |
verse = lines[index] | |
# post to Bsky | |
bs_client.send_post(text=verse) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A few other notes: I run this from a Raspberry Pi. There are three necessary files:
The secret sauce for communicating with Bluesky is the atproto Python library.