Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

๐Ÿ”— Automatically generate and tweet sentences like your daily tweets by using markov-chain.

License

Notifications You must be signed in to change notification settings

yuderobot/markov-tweet

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

79 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

markov-tweet

Automatically generate and tweet sentences like your daily tweets by using markov-chain.

Dependencies

  • Python 3.x
  • pandas
  • MeCab
  • mecab-python3
  • tweepy

Setup

Docker (Docker Compose)

  1. Download your tweets from Twitter (Download an archive of your data).
  2. Convert tweets.js to tweets.csv by using Twitter archive JS to CSV converter.
    Warning: Don't forget to rename .csv file!
  3. Put tweets.csv into data/ (please create new directory).
  4. Set environment variable in docker-compose.yml
  5. Copy banned.json.sample as banned.json.
  6. Configure banned words in banned.json as you like.

Manual

  1. Install Python 3.x, MeCab in the way of your environment.
  2. Run pip install -r requirements.txt to install depending Python packages.
  3. Download your tweets from Twitter (Download an archive of your data).
  4. Convert tweets.js to tweets.csv by using Twitter archive JS to CSV converter.
    Warning: Don't forget to rename .csv file!
  5. Put tweets.csv into app/.
  6. Copy .env.sample as .env.
  7. Put your tokens related to Twitter into .env. (You can get one from Developer Portal.)
  8. Copy banned.json.sample as banned.json.
  9. Configure banned words in banned.json as you like.

Run

Manual

python3 run.py

Docker Compose

  1. Create docker-compose.yml and paste the below and set your token in this file.
    version: '3'
    services:
        markov-tweet:
            restart: always
            container_name: markov-tweet
            image: ghcr.io/yuderobot/markov-tweet:master
            volumes:
              - "./data:/app/data"
            environment:
              # Twitter API related
              - CK=
              - CS=
              - AT=
              - AS=
              # Length of sentence
              - N=1
    
  2. Run docker-compose up -d. To update, run docker-compose pull before firing up the container.

Change settings

Remove RT, replies and URLs from source

  1. If you already run this bot, please delete triplets.pkl.
  2. Run python3 clean.py on this repository.
    Warning: Make sure you have tweets.csv inside the bot directory!
  3. Rename tweets.csv as tweets.csv.bak.
  4. Rename tweets_processed.csv as tweets.csv.
  5. Run the bot.

Change the number of sentences

  1. Open .env or docker-compose.yml and change the value of N.
  2. Run the bot.

Running this bot regularly

Use crontab to run this bot regularly.
If you use Docker image, you don't need to do this (already configured).

Example

*/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)

References

Example

License

This project is licensed under the MIT License.

About

๐Ÿ”— Automatically generate and tweet sentences like your daily tweets by using markov-chain.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Python 79.4%
  • Dockerfile 20.6%