This is the code behind twitter bot stuff_diff Some of the modifications made to this fork are specific for running on Stuff
For information on the original project see the upstream repo
In order to run diffengine you need to pick a directory location where you can store the diffengine configuration, database and diffs. For example I have a directory in my home directory, but you can use whatever location you want, you just need to be able to write to it.
The first time you run diffengine it will prompt you to enter an RSS or Atom feed URL to monitor and will authenticate with Twitter.
% diffengine /home/ed/.diffengine
What RSS/Atom feed would you like to monitor? https://inkdroid.org/feed.xml
Would you like to set up tweeting edits? [Y/n] Y
Go to https://apps.twitter.com and create an application.
What is the consumer key? <TWITTER_APP_KEY>
What is the consumer secret? <TWITTER_APP_SECRET>
Log in to https://twitter.com as the user you want to tweet as and hit enter.
Visit https://api.twitter.com/oauth/authorize?oauth_token=NRW9BQAAAAAAyqBnAAXXYYlCL8g
What is your PIN: 8675309
Saved your configuration in /home/ed/.diffengine/config.yaml
Fetching initial set of entries.
Done!
After that you just need to put diffengine in your crontab to have it run regularly, or you can run it manually at your own intervals if you want. Here's my crontab to run every 30 minutes to look for new content.
0,30 * * * * /usr/local/bin/diffengine /home/ed/.diffengine
You can examine your config file at any time and add/remove feeds as needed. It
is the config.yaml file that is stored relative to the storage directory you
chose, so in my case /home/ed/.diffengine/config.yaml.
Here is a list of known diffengine Twitter accounts. If you start one please send us a pull request or create an issue so it can be added here. For convenience Ryan Baumann's "diffengine" Twitter list aggregates many of these accounts.
- ap_diff: edits to the AP
- bbc_diff: edits to the BBC
- breitbart_diff: edits to Breitbart News
- canadaland_diff: edits to Canadaland
- cbc_diff: edits to The Canadian Broadcasting Corporation
- cnn_diff: edits to CNN
- dailymail_diff: edits to the Daily Mail
- fox_diff: edits to Fox News
- globemail_diff: edits to the The Globe and Mail
- guardian_diff: edits to The Guardian
- lapresse_diff: edits to La Presse
- repubblica_diff: edits to La Repubblica
- reuters_diff: edits to Reuters
- rt_edits: edits to RT
- stuff_diff: edits to Stuff
- telegraph_diff: edits to the Telegraph
- torstar_diff: edits to The Toronto Star
- wapo_diff: edits to The Washington Post
- whitehouse_diff: edits to the White House Blog
- wsj_diff: edits to the Wall Street Journal
- yyc_herald_diff: edits to the Calgary Herald
If you are setting multiple accounts, and multiple feeds if may be helpful to setup a directory for each account. For example:
- Toronto Sun
/home/nruest/.torontosun - Toronto Star
/home/nruest/.torontostar - Globe & Mail
/home/nruest/.globemail - Canadaland
/home/nruest/.canadaland - CBC
/home/nruest/.cbc
Then you will configure a cron entry for each account:
0,15,30,45 * * * * /usr/bin/flock -xn /tmp/globemail.lock -c "/usr/local/bin/diffengine /home/nruest/.globemail"
0,15,30,45 * * * * /usr/bin/flock -xn /tmp/torontosun.lock -c "/usr/local/bin/diffengine /home/nruest/.torontosun"
0,15,30,45 * * * * /usr/bin/flock -xn /tmp/cbc.lock -c "/usr/local/bin/diffengine /home/nruest/.cbc"
0,15,30,45 * * * * /usr/bin/flock -xn /tmp/lapresse.lock -c "/usr/local/bin/diffengine /home/nruest/.lapresse"
0,15,30,45 * * * * /usr/bin/flock -xn /tmp/calgaryherald.lock -c "/usr/local/bin/diffengine /home/nruest/.calgaryherald"
If there are multiple feeds for an account, you can setup the config.yml like so:
- name: The Globe and Mail - Report on Business
twitter:
access_token: ACCESS_TOKEN
access_token_secret: ACCESS_TOKEN_SECRET
url: http://www.theglobeandmail.com/report-on-business/?service=rss
- name: The Globe and Mail - Opinion
twitter:
access_token: ACCESS_TOKEN
access_token_secret: ACCESS_TOKEN_SECRET
url: http://www.theglobeandmail.com/opinion/?service=rss
- name: The Globe and Mail - News
twitter:
access_token: ACCESS_TOKEN
access_token_secret: ACCESS_TOKEN_SECRET
url: http://www.theglobeandmail.com/news/?service=rss
phantomjs: phantomjs
twitter:
consumer_key: CONSUMER_KEY
consumer_secret: CONSUMER_SECRET
Here's how to get started hacking on diffengine with pyenv:
% pyenv virtualenv 3.6.0 diffengine
% pyenv activate diffengine
% git clone https://github.com/docnow/diffengine
% cd diffengine
% pip install -r requirements
% pytest
============================= test session starts ==============================
platform linux -- Python 3.5.2, pytest-3.0.5, py-1.4.32, pluggy-0.4.0
rootdir: /home/ed/Projects/diffengine, inifile:
collected 5 items
test_diffengine.py .....
=========================== 5 passed in 8.09 seconds ===========================
