Skip to content

📰 Telegram bot that summarizes and posts top Hacker News stories to a Telegram channel

License

Notifications You must be signed in to change notification settings

johntad110/hnbriefs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hacker News Briefs Bot

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.

Overview

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.

Features

  • 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.

Requirements

  • 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)

Setup

  1. Clone the Repository:

    git clone https://github.com/johntad110/hnbriefs.git
    cd hnbriefs
  2. Install Dependencies:

    pip install -r requirements.txt
  3. 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>
    
  4. Run the Bot:

    python main.py

Usage

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.

File Structure

  • 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

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

📰 Telegram bot that summarizes and posts top Hacker News stories to a Telegram channel

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages