A simple framework for Twitter bots creating memes from Stack Exchange questions.
Take questions posted on a particular Stack Exchange site, generate a meme out of them and tweet them.
Uses the following APIs:
- @pi_stack (Raspberry Pi)
- @overflow_meme (Stack Overflow)
- @worldbuildingme (World Building)
- @askubuntumemes (Ask Ubuntu)
- @stackamemia (Academia)
Run your own instance
You can run your own instance of a Twitter bot following a particular Stack Exchange site. You need to register for API keys for the relevant services.
Sign up for an imgflip account and note your username and password.
Register for a Stack Exchange App Key and find your user ID for each site (click on your avatar to go to your user page and your ID is the number in the URL e.g.
806889in stackoverflow.com/users/806889/ben-nuttall) - note these are different for each site.
Install this project:
sudo pip3 install memeoverflow
Copy the example script
raspberrypi.py) and edit your copy to specify:
- the Stack Exchange site you wish to follow (get the exact string here) and your Stack Exchange API key
- your Twitter account's API keys
- your imgflip's username and password
- the path to your meme database file (can be a non-existent file, as long as the file location can be written to)
- Optionally, the path to your log file (can be a non-existent file, as long as the file location can be written to)
log file (optional)
If you want to log to a file, populate the
logfile function call as provided
If the path to the provided log file is writeable by your user, you are ready to
go. Here's an example of what you need to write logs to
Create the directory and chown it:
sudo mkdir /var/log/memeoverflow sudo chown ben: /var/log/memeoverflow
Set the logfile to e.g.
Simple launch (option 1)
- Run it directly:
Log entries will be written to stdout (and optionally to a log file if
specified). You'll have to keep the process active to keep it running, unless
you background it with
&. Alternatively, use systemd.
systemd launch (option 2)
Alternatively, use systemd:
Copy the example systemd service
sudo cp memeoverflow example.service /etc/systemd/system/memeoverflow-raspberrypi.service
Edit the service (edit
Descriptionand path to file in
sudo vim /etc/systemd/system/memeoverflow-raspberrypi.service
Reload systemctl daemon:
sudo systemctl daemon-reload
Enable and start the service:
sudo systemctl enable memeoverflow-raspberrypi.service sudo systemctl start memeoverflow-raspberrypi.service
Check the status:
sudo systemctl status memeoverflow-raspberrypi.service
If a log file is specified, log entries will be written there. They will also be
systemctl status which gives real evidence of it running correctly.