Hacker News
I’m an avid Hacker News consumer. It’s one of the first places I go in the morning and tend to visit it multiple times a day. It might as well be my default tab (though to be fair, I have something way cooler for that).
Recently, I noticed that YC has an open and official API for Hacker News so I set out to create a Slack bot (as a way to train myself for a product we’re working on).
This all took just a few hours and credit should all go to Slack’s great Events API that makes it so you don’t need to run a bot process at all times and enabled me to use StdLib alongside Botkit and put together a pretty decent experience.
Functionality
The bot currently supports almost all the public functionality of the API (except for users). Here’s how to use them:
Multiple Queries
You can get the bot to get you multiple post types all at once by asking for the different post types right in one message!
@hackernewsbot get me jobs and top stories
The bot cycles through all the commands that it sees and performs all of them and concatenates them in the same order. Since I asked it to get me jobs and top stories
, it’s showing the job postings first (since it showed up first in my text) and the top stories afterwards.
Top Stories
You can get the top stories (equivalent of going to the front page of HN).
@hackernewsbot top stories
It will show you the top stories whenever you say anything that contains the word top
.
New Stories
You can get the latest posts (equivalent of posts in /newest on HN).
@hackernewsbot new stories
It will show you the newest posts whenever you mention anything with the word new
in it.
Show HNs
You can get the latest Show HN posts (equivalent of /show on HN).
@hackernewsbot Show HNs
It’ll get you the latest Show HNs whenever you mention the word show
.
Job Posts
It can show you the latest job postings on HN (equivalent of /jobs on HN)
@hackernewsbot jobs
In the future, I’d like it support fetching posts by specific users (which the API supports) and potentially posting automatic notifications whenever a new post hits the front-page!
If you just want to install it to your Slack group, then go here.
If you want to read the code, here it is.
Hacker Noon is how hackers start their afternoons. We’re a part of the @AMI family. We are now accepting submissions and happy to discuss advertising & sponsorship opportunities.
If you enjoyed this story, we recommend reading our latest tech stories and trending tech stories. Until next time, don’t take the realities of the world for granted!