Find tweets that contain coincidental haikus, and tweet these beautiful poems.
You're a poet and
you didn't even know it.
Hey, that's a haiku! ✌️
- Add phrases to
data/track.txtto only search for tweets that contain any of the exact strings, one string per line (see the documentation abouttrackfor more info)- If file does not exist or is empty, gets tweets from the sample stream
- Add phrases to
data/ignore_tweet.txtto ignore tweets that contain tokens from any of these strings, one string per line. UsesANDandORlogic like the track list, but tokens forAND(a single line) can match anywhere. Also matches basic plural versions of words (e.g.,dogindata/ignore_tweet.txtwill matchdogsin a tweet's text). See the functiontext_contains_ignore_list_plural(inutils/text_utils.py) for more info.- Whether or not this file exists, by default this program ignores tweets with words read in the
get_ignore_tweet_listfunction (inutils/data_utils.py)
- Whether or not this file exists, by default this program ignores tweets with words read in the
- Add phrases to
data/ignore_profile.txtto ignore tweets from accounts whose descriptions contain any of these strings.ORlogic only; matches substrings. - Add pre-defined syllable counts to
data/syllables.json
- Install poetry as described here
- Install requirements:
poetry install
If running the app on Heroku (see below), .env is not needed but it may still be convenient to fill in the environment variables.
- Copy the (hidden)
.env_template.inifile to.env - Edit
.envto include your credentials (don't commit this file)
- If running the app on Heroku, you can easily provision a database for your app by installing the Postgres add-on (see below).
- Your database credentials will automatically be added to your app's Config Vars.
- If not running the app on Heroku, you'll need to set up your own database.
- Add your database credentials to
.env
- Add your database credentials to
- Run the application:
poetry run python haikuincidence/app.py- Alternatively, activate the virtual environment that poetry created by running
poetry shelland then run the script:python haikuincidence/app.py - Deactivate the virtual environment by running
deactivate
- Alternatively, activate the virtual environment that poetry created by running
These instructions use the Heroku CLI
- Fork this repo on GitHub and ensure you have a branch called
main - Create a new app on Heroku:
heroku create my-app-name - Install add-ons for:
- Papertrail
heroku addons:create papertrail -a my-app-name
- Postgres
heroku addons:create heroku-postgres -a my-app-name
- Papertrail
- Create a new token:
heroku authorizations:create -d "my cool token description"- Add the token to your GitHub repo's Secrets under the name
HEROKU_API_KEY
- Add the token to your GitHub repo's Secrets under the name
- Add your Heroku app's name to the GitHub repo's Secrets under the name
HEROKU_APP_NAME - Configure the application by adding environment variables as Config Vars
- Commit and push to your GitHub repo's
mainbranch- This can be through committing a change, merging a PR, or just running
git commit -m "empty commit" --allow-empty - This will use GitHub Actions to build the app using Docker and deploy to Heroku
- This can be through committing a change, merging a PR, or just running
- View the logs via the Heroku CLI or on Papertrail
I borrowed and adapted code from these nice resources. Thank you!
- Default oppressive word filter from this repo
- Syllable counting originally from this script
- Haiku checker inspired by this script
- URL regex from this gist
Copyright (c) 2018 Matt Mollison Licensed under the MIT license.