About Abbot
Abbot is a programmable bot that turns your team chat into a shared command center. We handle all the boilerplate of building and running these conmmands so that you can focus on making tools that help you ship faster.
We built Abbot because we saw the power of this style of work (called ChatOps), when we worked at GitHub. ChatOps made it possible for GitHub to work productively without meetings, while globally distributed. We think it’s a pretty great way to work, so we made it easy to use in Slack, Discord, and Microsoft Teams.
You can read more about Abbot here, check out our blog, or take a look at some of the other cool packages available as a one-click install from Abbot’s Package Directory.
README
@abbot hn
(defaults to point threshold of 100)
@abbot hn 200
(only show posts above 200 points)
@abbot hn 200 5
(only show top 5 posts above 200 points)
Usage
@abbot hn
(defaults to point threshold of 100)
@abbot hn 200
(only show posts above 200 points)
@abbot hn 200 5
(only show top 5 posts above 200 points)
Code
const axios = require(‘axios’);
const [first, second] = bot.arguments.split(‘ ‘);
const threshold = Number(first) || 100;
const limit = Number(second) || 10;
await axios.get(“https://node-hnapi.herokuapp.com/news?page=1”)
.then(res => {
return res.data
.map(({id, title, points}) => ({id, title, points}))
.filter(({points}) => points > threshold)
.sort((a, b) => b.points – a.points)
.map(({id, title, points}) => {
return`- [${points} points] <https://news.ycombinator.com/item?id=${id}|${title}>`
})
.slice(0, limit)
.join(‘\n’);
})
.then(text => bot.reply(text))
.catch(err => bot.reply(`Something went wrong! ${String(err)}`))
})();