2.3.8. Demo: Try Running the Bluesky Bot!#
Choose Social Media Platform: Reddit | Discord | Bluesky | No Coding
Running this Jupyter Notebook#
This page is called a “Jupyter Notebook” which it is a text page that has runnable Python code in it.
In order to run the code, you can look for the rocket button at the top which will give you an option to “launch binder.”
If you launch binder, it will take a while to load, but eventually show you a version of this Jupyter Notebook page in a code editor called Jupyter Lab.
In Jupyter Lab you can double click any section to edit it, and you can press the triangle “run” button to run the code (or display the text).
When the code runs, the little number to the left of the code block should change. There might also be some output from your action displayed below the code block.
So now you can go through the rest of this page and select and run each section of code.
Here is the bot code you can run!#
Our demo Bluesky bot code is below, broken up into different sections.
You can select each section of the code below and run it to see what it does.
By default this code uses a fake version of our Bluesky connection so it doesn”t connect to a real Bluesky account.
If you want to actually connect to your Bluesky account, you can put your Bluesky account name and password in the right code section below, and then when you run the code make sure to skip the code section that makes a fake Bluesky connection with “fake_atproto”.
Step 1: Load atproto (Bluesky) code#
# Load some code called "Client" from the "atproto" library that will help us work with Bluesky
from atproto import Client
(Optional) Step 1b: Make a fake Bluesky connection with the fake_atproto library#
For testing purposes, we”ve added this line of code, which loads a fake version of atproto, so it wont actually connect to Bluesky. If you want to try to actually connect to Bluesky, don’t run this line of code.
%run ../../fake_apis/fake_atproto.ipynb
Step 2: Login to Bluesky#
To use this on your real Bluesky account, copy your bluesky account name and login into the code below, replacing our fake bluesky name and password.
# Login to Bluesk
# TODO: put your account name and password below
client = Client(base_url="https://bsky.social")
client.login("your_account_name.bsky.social", "m#5@_fake_bsky_password_$%Ds")
Step 3: Send a Post to Bluesky#
# Send a Bluesky post
# TODO: modify the text in the quotes below to change what this bot posts to Bluesky:
client.send_post("This post was made by a computer program!")
This post was made by a computer program!