Automatically generate and tweet sentences like your daily tweets by using markov-chain.
- Python 3.x
- pandas
- MeCab
- mecab-python3
- Mastodon.py
- Download your tweets from Twitter (Download an archive of your data).
- Convert
tweets.js
totweets.csv
by using Twitter archive JS to CSV converter.
Warning: Don't forget to rename.csv
file! - Put
tweets.csv
intodata/
(please create new directory). - Set environment variable in
docker-compose.yml
- Copy
banned.json.sample
asbanned.json
. - Configure banned words in
banned.json
as you like.
- Install Python 3.x, MeCab in the way of your environment.
- Run
pip install -r requirements.txt
to install depending Python packages. - Download your tweets from Twitter (Download an archive of your data).
- Convert
tweets.js
totweets.csv
by using Twitter archive JS to CSV converter.
Warning: Don't forget to rename.csv
file! - Put
tweets.csv
intoapp/
. - Copy
.env.sample
as.env
. - Put your tokens related to Twitter into
.env
. (You can get one from Developer Portal.) - Copy
banned.json.sample
asbanned.json
. - Configure banned words in
banned.json
as you like.
python3 run.py
- Create
docker-compose.yml
and paste the below and set your token in this file.version: '3' services: markov-toot: restart: always container_name: markov-toot image: ghcr.io/yuderobot/markov-toot:master volumes: - "./data:/app/data" environment: # Twitter API related - CK= - CS= - AT= - AS= # Length of sentence - N=1
- Run
docker-compose up -d
. To update, rundocker-compose pull
before firing up the container.
- If you already run this bot, please delete
triplets.pkl
. - Run
python3 clean.py
on this repository.
Warning: Make sure you havetweets.csv
inside the bot directory! - Rename
tweets.csv
astweets.csv.bak
. - Rename
tweets_processed.csv
astweets.csv
. - Run the bot.
- Open
.env
ordocker-compose.yml
and change the value ofN
. - Run the bot.
Use crontab to run this bot regularly.
If you use Docker image, you don't need to do this (already configured).
*/20 * * * * cd /path/to/your/markov-tweet; /usr/bin/python3 /path/to/your/run.py
This definition make this bot run every 20 minutes. (*:00
, *:20
, *:40
)
This project is licensed under the MIT License.