dailywikiart is a simple Twitter bot that tweets random high-resolution works of art from wikiart's API. Each tweet includes a thumbnail, description of the work, and a link to the original image.
See it in the wild running off heroku: @dailywikiart
- Randomized selection of high resolution art images.
- MongoDB database ensures that an image is never tweeted more than once.
- Python 3.6+
- running mongodb instance
$ git clone [email protected]:kylepw/dailywikiart.git && cd dailywikiart $ python -m venv venv && source venv/bin/activate (venv) $ pip install -r requirements.txt
- Create a Twitter application with the Twitter account you wish to use with the bot. Make sure you set Read and Write access and jot down these values: consumer key, consumer secret, access token, and access token secret.
Set the required environment variables as follows:
- API_KEY
Your application's consumer key.
- API_SECRET
Your application's secret key.
- ACCESS_TOKEN
Your access token.
- ACCESS_SECRET
Your access token secret.
- MONGODB_URI
Your mongodb URI
- MONGODB_DBNAME
Database name
You can use python-dotenv, pipenv, virtualenv or bash to set the environment variables.
One way to do it (replacing
XXX
's with your values):$ echo -e "API_KEY=XXX\nAPI_SECRET=XXX\nACCESS_TOKEN=XXX\nACCESS_SECRET=XXX\nMONGODB_URI=XXX\nMONGODB_DBNAME=XXX" >> .env $ set -a; source .env; set +a
(venv) $ # Make sure virtual environment is active (venv) $ # and you have a mongodb instance running (venv) $ python bot.py
or to view logs:
(venv) $ LOGLEVEL=info python bot.py
You could run this bot at a set time using any scheduler such as crontab, systemd, or launchd.
This bot is currently running on heroku with a mongodb add-on and clock dyno.