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.4.tar.gz (9.9 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.4-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hnbot-0.0.4.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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.4.tar.gz
Algorithm Hash digest
SHA256 017282b04bdae942e8601e97b1932d9a950abccf8e8a130c85b12d206e20f692
MD5 2fef88d9859aa90309e89608a9345ba9
BLAKE2b-256 096097fb2f2bbef6154c35178e4c69e7af93c26a96bd59ae748083be9db2c636

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hnbot-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 99ce36e5da89e6a34377dacf1c180987625aaf72732a931f4683e52cc2e09bc7
MD5 cccc48623b1e217deac2997bf575db86
BLAKE2b-256 0501856cfe4c40cf2826e8699147038e2beb446d27e2e7583e5709a04e5d991e

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