i stole this from autumn, modified to run multiple models with different creds.
to test the model run
python generate.py --model model.json
provide credentials to post.
python generate.py --model model.json --domain shrimp.domain.tld --token "TOKEN" --pds pds.domain.tld --did "DID" --password "APPPASSWORD"
modify model parameters
python generate.py --model model.json --overlap 5 --tries 2000 --min_words 2
there are changes to cat.py to merge multiple files at once
python ./markov/cat.py first.json second.json third.json fourth.json
i just stole from sneexy's repo the innovation i bring is just a script that converts mastodon to misskey for the sake of having journalist posts work with this mate also i guess nix flake so i don't need to put a bullet into my head dealing with python (instead, i blow my head off dealing with nix )
also im adding bsky posting because im awesome i guess ...
minimally modified fork of kopper's markov bot to post to iceshrimp.net. while still only taking in misskey exports. that's all i needed.
clone the repository somewhere:
git clone https://forged.synth.download/sneexy/markov.git
cd markov
ideally, create a venv first:
python -m venv venv
source ./venv/bin/activate # assuming we're still in the markov folder - you'll need to do this everytime you want to use the bot, make a script or something to make it easier
now install everything:
pip install -r requirements.txt
python -m spacy download en_core_web_sm
import your misskey notes export:
python import-misskey.py name-of-your-notes-export.json # will take a bit depending on how large your export is
mv xxxxx.model.json model.json # exported file will be named something else, rename it to model.json to prevent it from erroring out when generating
add your iceshrimp.net user/bot account token & bsky bot account's app password:
echo "TOKEN='InsertVerySecureTokenHere'" > secrets__.py
echo "BSKY='YourEpicBskyAppPassword'" >> secrets__.py
...then edit generate.py
and modify the requests.post
section near the bottom to point the url to your instance, and for bsky posting add the bot's handle in place of "markov.autumn.town", and edit the pds_url variable with your pds' url.
ℹ️ alternatively, if you'd like to use this to post to misskey, replace it with this (replacing yourinstance.tld
with your instance):
requests.post("https://yourinstance.tld/api/notes/create", json={
'i': secrets__.TOKEN,
'visibility': 'home',
'noExtractMentions': True,
'noExtractHashtags': True,
'text': text,
#'cw': 'markov chain generated post'
})
...or perhaps with mastodon (untested):
requests.post("https://yourinstance.tld/api/v1/statuses", json={
"status": text,
#"spoiler_text": "markov chain generated post",
"visibility": "unlisted"
}, headers={"Authorization": f"Bearer {secrets__.TOKEN}"})
finally, make a markov generated post:
python generate.py
you can use a cronjob/crontab on your user to automate posting, for example, to post every two hours:
0 */2 * * * cd /home/ruben/markov && source /home/ruben/markov/venv/bin/activate && python /home/ruben/markov/generate.py
here's a dumb and probably over engineered script i made to interact with the bot. you may edit this and use it to your own will and needs.
#!/bin/bash
# cding into the markov directory is required otherwise it fails to load the model
CURRENT_DIR=$(pwd)
cd /home/ruben/markov && \
source /home/ruben/markov/venv/bin/activate && \
python /home/ruben/markov/generate.py && \
cd $CURRENT_DIR