hn-responder
A Python script that replies to every @newsycombinator tweet with a link to the article's comments page.
This script uses the Twitter API and Hacker News API via Firebase. It reads all tweets for the authenticated Twitter account and puts them into a queue. A background thread takes the tweets from the queue. If a tweet is from the @newsycombinator Twitter account, the background thread goes through all top Hacker News articles via the Firebase API and selects the article that matches the title of the tweet. It then sends out a reply tweet with the link to the article's comments page.
Setup
To run the script, use the following steps:
-
Install the Python modules
requests-oauthlib
andpython-firebase
:pip install requests-oauthlib pip install python-firebase
-
Create a Twitter app on https://apps.twitter.com/app/. Get the tokens and secrets for your Twitter app on the "Keys and Access Tokens" page.́
-
Create file
twitter-secrets.json
with following contents (replace with your actual tokens and secrets):{ "access_token": "12345", "access_token_secret": "abcdefg", "consumer_key": "1q2w3e4", "consumer_secret": "ABCDEFG" }
-
Execute script
hn-responder.py
from the command line. Note that it will run forever until killed.python hn-responder.py