A Telegram bot that posts new hot stories from Hacker News to the Hacker News Briefs Telegram channel, including a short summary of each story.
The Hacker News Briefs Bot fetches top stories from Hacker News every 10 minutes and posts those that have reached a score of 100 or more to a Telegram channel, along with a brief summary.
- Fetches top stories from Hacker News using the Hacker News API.
- Summarizes each story using a language model.
- Posts the title, score, summary, and links to the article and comments to a Telegram channel using the Telegram Bot API.
- Python 3.x
- A Telegram bot token (register via BotFather)
- An API key for a language model (e.g., OpenAI's GPT-4, or Google's Gemini)
-
Clone the Repository:
git clone https://github.com/johntad110/hnbriefs.git cd hnbriefs
-
Install Dependencies:
pip install -r requirements.txt
-
Configure Environment Variables: Create a
.env
file in the project root and add your API keys:OPENAI_API_KEY=<YOUR_OPENAI_API_KEY> TG_BOT_TOKEN=<YOUR_TELEGRAM_BOT_TOKEN> TG_CHAT_ID=<YOUR_TELEGRAM_CHAT_ID>
-
Run the Bot:
python main.py
Once the bot is running, it will automatically fetch top stories from Hacker News every 10 minutes, summarize them, and post to the configured Telegram channel.
main.py
: Coordinates the entire process, including fetching stories, summarizing, and posting to Telegram.hn.py
: Contains functions to interact with the Hacker News API.telegram.py
: Contains functions to interact with the Telegram Bot API.summarizer.py
: Contains functions to summarize articles using a language model API.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.