-
-
Save akash-joshi/5b6d7fc0a61885fc84004892a45b23b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sendHn = async (ids) => { | |
const currentDate = new Date(); | |
currentDate.setDate(currentDate.getDate() - 1); | |
const hnResponse = await axios.get( | |
`https://hn.algolia.com/api/v1/search?tags=story&numericFilters=created_at_i>${ | |
currentDate.valueOf() / 1000 | |
}` | |
); | |
const message = ` | |
Today's top HN stories were: | |
${hnResponse.data.hits | |
.map( | |
(hit, index) => | |
`\n\n${index + 1}. ${hit.title}\nhttps://news.ycombinator.com/item?id=${ | |
hit.objectID | |
}\nPoints: ${hit.points}` | |
) | |
.join("")} | |
`; | |
for (const id of ids) { | |
bot.telegram.sendMessage(id, message); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment