🐶🐱🐣 This is a twitter bot that posts a random adoptable pet from Chemnitz's shelter.
CoffeeScript Shell Ruby
Clone or download
Pull request Compare This branch is 45 commits ahead of codeforamerica:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
API
lib
.gitignore
Gemfile
Gemfile.lock
LICENSE
README.md
Rakefile
template.env

README.md

CutePetsChemnitz

Post an random pet from shelter Chemnitz (OT Röhrsdorf) on Twitter @petschemnitz

About

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

Setup & Deployment

nodejs

https://nodejs.org/

ruby

sudo apt-get install ruby ruby-dev rake
sudo gem install bundler

Redis

sudo apt-get install redis

Configure Redis in src/server.coffee

Repo

cd /opt/
git clone https://github.com/CodeforChemnitz/CutePetsChemnitz.git
cd CutePetsChemnitz

API

The API is available via http://127.0.0.1:3000/

Install

cd API
npm install
npm run-script build

Run

node lib/cron.js
node lib/server.js

Deploy

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

Twitter

  1. Create a new twitter app.
  2. On the API key tab for the Twitter app, modify permissions so the app can Read and Write.
  3. Create an access token. On the API Key tab in Twitter for the app, click Create my access token
  4. 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.

Environmental variables

  1. Create a local .env file: cp template.env .env
  2. Fill in the twitter keys created above.

Install

bundler install

Run

rake

Deploy

Adding a Cronjob:

# Post a pet every hour
5 9-22/2 * * *  root cd /opt/CutePetsChemnitz && rake

Hat tips