Userlist Sync#
A small tool written in Ruby for adding all users with handles matching some kind of pattern (e.g. all *.gov) to a user list on Bluesky.
How to use#
-
Deploy this repo to some kind of server using a method of your choice (manual
git clone, Capistrano, etc.). -
Make sure you have a reasonably new version of Ruby installed there. Any recent Linux distribution should have Ruby 3.0 or newer available as a package (as of January 2025, the latest version is 3.4.1, 3.1.x is in security maintenance mode, and 3.0.x is EOL); however, this code should work with 2.6 or 2.7 too, though that's not recommended. You can also install Ruby using tools such as RVM, asdf, ruby-install or ruby-build.
-
cdinto the project directory and install gem dependencies usingbundle. You might want to configure it to install the gems into the local directory instead of system-wide, e.g.:
bundle config --local bundle_path ./vendor
bundle
- Create a
config/auth.ymlfile with authentication info for the account that manages the lists. It should look like this (sorry, no OAuth yet):
id: your.handle
pass: app-pass-word
This file will also be used to keep access tokens (try to delete the tokens from there if something goes wrong and the app can't authenticate).
- Create a second config file
config/config.ymlwith options for the list and handles:
jetstream_host: jetstream2.us-east.bsky.network
handle_patterns:
- "*.uk"
list_key: 3lqwertyuiop
Fields in the config:
jetstream_host- Jetstream server hostname, see herehandle_patterns- list of one or more handle patterns to look for; the entries are currently not regexps, but just simple patterns with*matching one or more characterslist_key- the rkey of the list to which accounts should be added (the last part of the list URL)
- Test if the app works by running:
./run_sync.rb
The app will save some data like current cursor and list of known accounts to data/data.json (on first run, it will fetch the initial state of the list first).
- Use something like
systemdto launch the service automatically and keep it running (you can find a sample systemd service file in the dist folder).
Credits#
Copyright © 2024-25 Kuba Suder (@mackuba.eu).
The code is available under the terms of the zlib license (permissive, similar to MIT).
Bug reports and pull requests are welcome 😎