This Python script generates Markov chain text based on the posts of a Mastodon account and posts them to another Mastodon account. It also periodically updates its dataset and posts a new status.
-
Clone this repository or download the script
chain.py
. -
Install the required dependencies by running:
pip install markovchain mastodon.py python-dotenv
-
Create a
.env
file in the same directory as the script and add the following variables:MASTODON_BASE_URL=<source Mastodon instance base URL> MASTODON_ACCESS_TOKEN=<source Mastodon account access token> DESTINATION_MASTODON_BASE_URL=<destination Mastodon instance base URL> DESTINATION_MASTODON_ACCESS_TOKEN=<destination Mastodon account access token> DESTINATION_MASTODON_CHAR_LIMIT=<destination Mastodon character limit> SOURCE_MASTODON_ACCOUNT_ID=<source Mastodon account ID>
-
Run the script by executing in the repository directory:
python chain.py
-
The script will fetch recent posts from the source Mastodon account, generate Markov chain text, and post it to the destination Mastodon account at random intervals between 30 minutes and 3 hours.
-
Press
Ctrl+C
to stop the script.
- Ensure that both the source and destination Mastodon accounts have appropriate permissions and visibility settings for posting.
- If you need to change any Mastodon or environment variables, update them in the
.env
file. - Make sure to customise the script according to your needs, such as adjusting the character limit for generated text or the update interval for the dataset.