This is a Rust program that fetches the top 500 stories from Hacker News and sends them to a Telegram chat.
It deduplicates the stories and only sends the new ones.
Written as a learning exercise.
$ export TELEGRAM_BOT_TOKEN=your_token
$ export TELEGRAM_CHAT_ID=your_chat_id
$ docker build -t hn500 .
$ docker run --name hn500 -e TELEGRAM_BOT_TOKEN -e TELEGRAM_CHAT_ID hn500
$ export TELEGRAM_BOT_TOKEN=your_token
$ export TELEGRAM_CHAT_ID=your_chat_id
$ docker-compose up -d
The following environment variables are used to configure the bot:
TELEGRAM_BOT_TOKEN
: Your Telegram bot token. You can get one by talking to the BotFather.TELEGRAM_CHAT_ID
: The ID of the chat where you want to send the stories. You can get this by talking to the@userinfobot
bot.
The project is structured as follows:
src/main.rs
: The entry point of the application.src/client.rs
: Handles fetching the top 500 stories from Hacker News.src/broadcast.rs
: Handles sending the stories to the Telegram chat.src/config.rs
: Handles loading the configuration from the environment.src/models.rs
: Contains the data models for the Hacker News stories.src/utils.rs
: Contains utility functions.src/conversions.rs
: Contains functions for converting between different data models.
- Add tests
- Add CI
- Add logging
- Add Dockerfile
- Add documentation