pywws.service.bluesky
Post messages to Bluesky.
Bluesky is a micro-blogging system that is a whole lot better than the cesspool Twitter has become under Space Karen. This module sends “skeets”, with optional image files, typically to report on weather conditions every hour.
Create account: https://bsky.app/
Example
weather.iniconfiguration:[bluesky] handle = bishopstonwthr.bsky.social password = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx [hourly] text = ['skeet.txt', '24hrs.txt'] plot = ['24hrs.png.xml', 'rose_12hrs.png.xml'] services = [('bluesky', 'skeet.txt'), ('ftp', '24hrs.png', 'rose_12hrs.png')]
Create an account
You could post weather updates to your regular Bluesky but it may be cleaner to have a separate account just for weather reports.
The pywws.service.bluesky module requires you to install an
additional dependency:
sudo pip install atprototools
Create a template
A “skeet” is a short text of up to 300 characters. It’s up to you what to
put in your “skeet” but an example is included to get your started. Copy
the example template skeet.txt to your template directory, then edit
it to suit your preferences. (Note hashtags are not automatically
rendered as hash tags, and getting them to work is complicated as you
have to figure out the start/end position in the post text, that’s just
too hard for this currently). You should also check it uses the same text
encoding as your other templates. The example template includes a
media line to send a graph. Either remove this or copy the example
graph template tweet.png.xml to your graph templates directory, if
you don’t already have one there.
Now generate a skeet file from your template, for example:
python -m pywws.template ~/weather/data ~/weather/templates/skeet.txt skeet.txt
cat skeet.txt
Post your first skeet
Now you are ready to run pywws.service.bluesky:
python -m pywws.service.bluesky ~/weather/data skeet.txt
If this works, your new Bluesky account will have posted its first weather report. (You can delete the skeet.txt file now.)
Add Bluesky posts to your hourly tasks
Edit the [hourly] section in weather.ini. If your skeets include
one or more graphs you need to add the graph templates to the plot
list. Note that if you reuse your Twitter graph you only need to
generate it once. Add your skeet template to the text list. Finally,
add bluesky to the services list, with an option specifying the
template processing result. For example:
[hourly]
text = ['skeet.txt']
plot = ['tweet.png.xml']
services = [('bluesky', 'skeet.txt')]
You could use the [logged], [12 hourly] or [daily] sections
instead, but I think [hourly] is most appropriate for Bluesky
updates.
Include images in your skeet
Each post contains up to four images, and each image can have its own alt text and is limited to 1,000,000 bytes in size. However, the atprototools libary used to interface with Bluesky is currently coded to just manage a single image; it also cannot accept ALT text for the image.
To include an image ensure the first line of the skeet is media path
where path is the file name or full path for file
that are not in your “output” directory (a subdirectory of your work
directory called output). . The “skeet_media.txt” example template
shows how to do this.
The image could be from a web cam, or for a weather forecast it could be
an icon representing the forecast. To add a weather graph you need to
make sure the graph is drawn before the tweet is sent. The
pywws.regulartasks module processes graph and text templates
before doing service uploads, so you can include the graph drawing in
the same section. For example:
[hourly]
plot = ['skeet.png.xml']
text = ['skeet_media.txt']
services = [('bluesky', 'skeet_media.txt')]
Classes
|
Comments or questions? Please subscribe to the pywws mailing list http://groups.google.com/group/pywws and let us know.