Skip to content

Receive en email whenever a keyword is used / mentioned on ycombinator hackernews

Notifications You must be signed in to change notification settings

jbarbier/hackernews_alert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

Hacker News Alerts

A simple Ruby script to be alerted by email whenever one specific keyword is mentioned on YCombinator Hacker News (not just on the front page). By design this script covers the frontpage, the new submitted articles and comments. For hosted service and more features see HNWatcher.

The code is based on the hnsearch API / ThriftDB Search API

Usage

Modify the file alert_hackernews.rb & configure your database as follow. Then add the script to the cron jobs. And wait for alerts :)

Keyword

Update the file alert_hackernews.rb, line 10

look_for = 'docker'

Email

Update the file alert_hackernews.rb from line 14 to 16

email_from = 'your@email_from.io'
email_to = 'your@email_to.com'
email_title = "New mention of #{look_for} on HN"

Database

Create the MySQL database and add the table from the mysql.db script file

CREATE TABLE `logs` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `id_hn` int(11) NOT NULL,
  `id_parent_hn` int(11) DEFAULT NULL,
  `create_ts` date NOT NULL,
  `type` enum('SUBMISSION','COMMENT') NOT NULL DEFAULT 'SUBMISSION',
  `title` varchar(1024) DEFAULT NULL,
  `url` varchar(1024) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=63 DEFAULT CHARSET=utf8;

Update the file alert_hackernews with the right credentials (lines 11-12-13)

db_db = 'hn_alert'
db_username = 'mdm'
db_password = 'charmes_g'

Cron

Add the script as a cron job with the frequency you want it to check for your keyword on HackerNews

Next steps

Be free to use the code and improve it to:

  • add more than one keyword (being able to monitor several keywords on HackerNews)
  • add more than one email to be alerted
  • add more information (usernames, points, ...)
  • add a back office to list all mentionned on HackerNews (from the database)
  • add a back office option to manage the keywords and the emails for each keyword

Questions?

If you have any questions, feel free ton contact me on twitter

HNWatcher

For hosted service and more features see HNWatcher.

Have fun!

Bitdeli Badge

About

Receive en email whenever a keyword is used / mentioned on ycombinator hackernews

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages