Generates random sentences from your tweet history using the Markov chain, and post them into Twitter.
Download your Twitter archive from Twitter, which is available on Settings > Account > "Request your archive"
Register your application on Twitter Application Management with "Read and Write" permissions at least, then set your credentials to the following environment variables.
MARKOV_BOT_CONSUMER_KEY
MARKOV_BOT_CONSUMER_SECRET
MARKOV_BOT_ACCESS_TOKEN
MARKOV_BOT_ACCESS_TOKEN_SECRET
$ docker run \
-e MARKOV_BOT_CONSUMER_KEY=... \ # or --env-file=...
-e MARKOV_BOT_CONSUMER_SECRET=... \
-e MARKOV_BOT_ACCESS_TOKEN=... \
-e MARKOV_BOT_ACCESS_TOKEN_SECRET=... \
ryotakameoka/markov-bot \
--tweet-js=...
Scheduled execution on Heroku
Note that tweet.js
must be hosted somewhere (with a public URL).
Personally I have a repository for the file and deploy it to Netlify.
Instead, you can also build your own image extending docker.io/ryotakameoka/markov-bot
which contains your tweet.js
inside and push it to Heroku Container Registry.
https://devcenter.heroku.com/articles/heroku-cli#download-and-install
$ heroku login
Replace <APP_NAME>
with an arbitrary name.
$ heroku apps:create <APP_NAME>
$ heroku config:set --app=<APP_NAME> MARKOV_BOT_CONSUMER_KEY=...
$ heroku config:set --app=<APP_NAME> MARKOV_BOT_CONSUMER_SECRET=...
$ heroku config:set --app=<APP_NAME> MARKOV_BOT_ACCESS_TOKEN=...
$ heroku config:set --app=<APP_NAME> MARKOV_BOT_ACCESS_TOKEN_SECRET=...
Add Heroku Scheduler to your app
$ heroku addons:create --app <APP_NAME> scheduler:standard
Pull the pre-built Docker image from Docker Hub
$ docker pull docker.io/ryotakameoka/markov-bot
Note that Heroku Scheduler only supports "web" dyno.
$ heroku container:login
$ docker tag docker.io/ryotakameoka/markov-bot registry.heroku.com/<APP_NAME>/web
$ docker push registry.heroku.com/<APP_NAME>/web
$ heroku container:release --app <APP_NAME> web
$ heroku addons:open --app <APP_NAME> scheduler
$ --tweet-js <URL_OF_TWEET_JS>
Option | Description | Example values |
---|---|---|
--tweet-js |
File path or URL for tweet.js (required) | ./tweet.js https://example.com/path/to/tweet.js |
--order |
Order of Markov chain, in positive integer (optional) | 2 3 |
This software is distributed under BSD3 lisence.