Post an random pet from shelter Chemnitz (OT Röhrsdorf) on Twitter @petschemnitz
Originated as a project of Team Denver during the 2014 fellowship at Code for America. Originally specific to Denver, it's been redeployed by a few cities. Check out this twitter list to see where.
Links to Bot
sudo apt-get install ruby ruby-dev rake
sudo gem install bundler
sudo apt-get install redis
Configure Redis in src/server.coffee
cd /opt/
git clone https://github.com/CodeforChemnitz/CutePetsChemnitz.git
cd CutePetsChemnitz
The API is available via http://127.0.0.1:3000/
cd API
npm install
npm run-script build
node lib/cron.js
node lib/server.js
Install Service
sudo ln -s /opt/CutePetsChemnitz/API/forever_cutepets /etc/init.d
sudo update-rc.d forever_cutepets defaults
sudo service forever_cutepets start
Adding a Cronjob:
# Scrape shelters every 6 hours
50 */6 * * * root node /opt/CutePetsChemnitz/API/lib/cron.js
- Create a new twitter app.
- On the API key tab for the Twitter app, modify permissions so the app can Read and Write.
- Create an access token. On the API Key tab in Twitter for the app, click Create my access token
- Take note of the values for environment set up below. Note: It's important to change permissions to Read/Write before generating the access token. The access token is keyed for the specific access level and will not be updated when changing permissions.
- Create a local .env file:
cp template.env .env
- Fill in the twitter keys created above.
bundler install
rake
Adding a Cronjob:
# Post a pet every hour
5 9-22/2 * * * root cd /opt/CutePetsChemnitz && rake
-
Kudos to Darius for his great guide on how to make a twitter bot.
-
And kudo to Erik for the twitter gem.