Skip to content

Latest commit

 

History

History
135 lines (93 loc) · 4.07 KB

README.md

File metadata and controls

135 lines (93 loc) · 4.07 KB

Meme Overflow

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:

Instances

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.

API keys

  1. Sign up for a Twitter account, create an app and get your four API keys.

  2. Sign up for an imgflip account and note your username and password.

  3. 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. 806889 in stackoverflow.com/users/806889/ben-nuttall) - note these are different for each site.

Essential setup

  1. Install this project:

    sudo pip3 install memeoverflow
  2. Copy the example script example.py (e.g. to 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 in the example.py script.

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 /var/log/memeoverflow/:

  1. Create the directory and chown it:

    sudo mkdir /var/log/memeoverflow
    sudo chown ben: /var/log/memeoverflow
  2. Set the logfile to e.g. /var/log/memeoverflow/raspberrypi.log in raspberrypi.py

Simple launch (option 1)

  1. Run it directly:
python3 raspberrypi.py

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:

  1. Copy the example systemd service memeoverflow-example.service into /etc/systemd/system/:

    sudo cp memeoverflow example.service /etc/systemd/system/memeoverflow-raspberrypi.service
  2. Edit the service (edit Description and path to file in ExecStart):

    sudo vim /etc/systemd/system/memeoverflow-raspberrypi.service
  3. Reload systemctl daemon:

    sudo systemctl daemon-reload
  4. Enable and start the service:

    sudo systemctl enable memeoverflow-raspberrypi.service
    sudo systemctl start memeoverflow-raspberrypi.service
  5. 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 visible in systemctl status which gives real evidence of it running correctly.