Skip to main content

No project description provided

Project description

Hacker News Bot

A Telegram bot that monitors Hacker News for trending articles, generates AI-powered summaries of the discussions, and delivers them straight to your Telegram chat.

Features

  • RSS feed monitoring — fetches top stories from hnrss.org filtered by minimum points
  • AI-powered summaries — uses OpenAI to distill HN comment threads into concise, structured articles
  • Telegraph publishing — creates readable long-form pages on Telegraph
  • Telegram notifications — sends formatted messages with links to the original article, HN discussion, and the generated summary
  • Redis deduplication — tracks processed entries to avoid sending duplicate notifications
  • Batch execution — each CLI run processes one feed batch and exits cleanly for cron or CI scheduling
  • Concurrent processing — handles multiple articles in parallel with configurable concurrency limits
  • Retry with backoff — automatically retries transient HTTP failures

How It Works

hnrss.org RSS feed
        │
        ▼
  Filter by points
        │
        ▼
  Fetch HN comments ──► HTML → Markdown
        │
        ▼
  OpenAI summarisation
        │
        ▼
  Publish to Telegraph
        │
        ▼
  Notify via Telegram

Quick Start

Prerequisites

Install & Run

# Clone the repository
git clone https://github.com/narumiruna/hnbot.git
cd hnbot

# Install dependencies
uv sync

# Configure environment variables
cp .env.example .env
# Edit .env and fill in the required values

# Run the bot
uv run hnbot

Each invocation processes one feed batch and exits. Use cron, systemd timers, or GitHub Actions if you want recurring runs.

Install from PyPI

pip install hnbot

Docker

docker build -t hnbot .
docker run --env-file .env hnbot

Configuration

All settings are loaded from environment variables (or a .env file). See .env.example for the full template.

Required

Variable Description
OPENAI_API_KEY OpenAI API key
BOT_TOKEN Telegram bot token
CHAT_ID Telegram chat ID to receive notifications

Optional

Variable Default Description
OPENAI_BASE_URL (OpenAI default) Custom OpenAI-compatible API endpoint
OPENAI_MODEL gpt-5-mini LLM model to use for summarisation
ARTICLE_LANG Traditional Chinese (台灣正體中文) Output language for generated articles
LOGFIRE_TOKEN Logfire token for observability
REDIS_HOST localhost Redis host
REDIS_PORT 6379 Redis port
REDIS_DB 0 Redis database number
FEED_POINTS 100 Minimum HN points threshold for feed entries
HTTP_TIMEOUT_SECONDS 10.0 HTTP request timeout (seconds)
HTTP_USER_AGENT hnbot/0.0.0 HTTP User-Agent header
COMMENTS_FETCH_CONCURRENCY 1 Max parallel comment fetches
ARTICLE_PIPELINE_CONCURRENCY 3 Max parallel article generation tasks
CHUNK_SIZE 200000 Max characters per chunk for LLM processing
BATCH_SLEEP_SECONDS 0.5 Delay before processing a batch

Development

# Install all dependencies (including dev)
uv sync

# Run the full development gate (format → lint → type-check → test)
just all

# Or run individual steps
just format   # ruff format
just lint     # ruff check --fix
just type     # ty check
just test     # pytest with coverage

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hnbot-0.0.5.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hnbot-0.0.5-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file hnbot-0.0.5.tar.gz.

File metadata

  • Download URL: hnbot-0.0.5.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.12 {"installer":{"name":"uv","version":"0.11.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for hnbot-0.0.5.tar.gz
Algorithm Hash digest
SHA256 18dae8745f2333c9385e338044b0cf4579607d79efcfbbc06221a2bb60ef6715
MD5 a185df2a97c13f91dc36daa5014a43fe
BLAKE2b-256 cc1e918cd33798214ac3011ab47b34245be029562f098a53f8b5510634d0e797

See more details on using hashes here.

File details

Details for the file hnbot-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: hnbot-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.12 {"installer":{"name":"uv","version":"0.11.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for hnbot-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b60f2794b5bbb70573fda8c7ebc3bf8f38ebc251e2c9ba376d9c6d23836240d8
MD5 d8a1df2345a423f2c41bb325afda35f9
BLAKE2b-256 b664a81aaefab2f086c7d22ab80143bd1a446cfaa0a49ea8c029e40bee2eb0c8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page