EFForg / cryptobot-email

GNU Affero General Public License v3.0
61 stars 11 forks source link

CryptoBot

CryptoBot Email is an email bot that helps people learn how to use OpenPGP. You send CryptoBot a PGP-encrypted and signed email (probably using GnuPG) and it responds telling you how you do, and offering advice.

Getting Started

Start by copying config_template.py into config.py and editing it.

$ cp config_template.py config.py

Set all of these settings:

This is a Python project with some external dependencies. We recommend using virtualenv:

$ virtualenv env
$ . env/bin/activate
(env) $ pip install -r requirements.txt
(env) $ ./bot.py
# when you're done
(env) $ deactivate

Unsubscribes

To avoid exploitation as an automated spam cannon, cryptobot can optionally maintain a database of unsubscribers. It requires one additional setup step. After installing requirements, uncomment the DATABASE_URL in config.py, and run

./unsubscribe.py --setup

This will create the necessary database tables and generate a random salt for hashing email addresses. Once that's done, you can add emails to the database by running

./unsubscribe.py --add foo@example.com

Alternatively you can run the included Flask app to serve a simple unsubscribe form for people to unsubscribe themselves.

./app.py    # http://localhost:5000/unsubscribe

For simplicity, you can use an sqlite database, which is created as a normal file in the directory of your choosing, and does not incur any extra dependencies. However, for better concurrency handling, you may want to install and use postgresql, which will require the psycopg2 python module along with some additional system configuration:

sudo apt-get install postgresql
sudo -u postgres createuser -P -s -e cryptobot
createdb cryptobot -O cryptobot
sudo apt-get install postgresql-server-dev-9.1
. env/bin/activate
pip install psycopg
deactivate

Dev Notes

On linux systems: if you get an error while trying to install requirements.txt, like "fatal error: Python.h: No such file or directory" $ sudo apt-get install python-dev

To run the tests:

$ ./test.py

By default, the tests skip key generation, which can be slow and use up entropy. To include these tests, run:

$ ./test.py --slow

Relevant specs: