Post to Mastodon
Project description
postodon
Randomly posts things to Mastadon from a list using the API.
The list of posts is a JSON file:
[
{"content": "Text of the post", "id": 1, "status": "unposted"},
...,
]
The command postodon
randomly selects an unposted post, posts it to Mastodon, and marks it as posted in the list. If there are no unposted items, an already-posted item is used instead.
Installation
Install:
python3 -m venv .venv
source .venv/bin/activate
pip install postodon
Usage
Setup
- Register an application as described here: https://docs.joinmastodon.org/client/token/#app
- Get an access token as described here: https://docs.joinmastodon.org/client/authorized/#flow
- Securely store the returned
access_token
for future reference - Edit
config.json
to include the name of the Mastodon instance and the name of the posts file, e.g.posts.json
Use
To use, put the access token in an environment variable called AUTH_TOKEN
:
export AUTH_TOKEN=<your_access_token_here>
To select a random post from the list without either updating the list or posting (dry-run mode):
postodon -n
To publicly post a random post, marked as English, and update the list (mark the post having been posted):
postodon
NB if there are no unposted posts left in the list, this will return a random post from the 'posted' selection.
To add new posts to the list for future posting, add them to the specified posts file.
Development
To contribute to this library, first checkout the code. Then create a new virtual environment:
cd postodon
python -m venv .venv
source .venv/bin/activate
Now install the dependencies and test dependencies:
pip install -e '.[dev,tests]'
To run the tests:
pytest
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.