Skip to main content

Forward links from RSS/Atom feeds to messengers

Project description

FeedForBot

PyPI Version PyPI Downloads Docker Pulls GHCR Ruff

Monitors RSS/Atom feeds on a cron schedule and forwards new entries to Telegram. Supports multiple feeds, Jinja2 message templates, file-based caching to avoid duplicate sends, and optional Sentry integration for error tracking.

Features

  • Multiple feeds — run any number of listener/transport pairs, each with its own cron schedule
  • Jinja2 templates — full control over message formatting with access to article fields ({{ TITLE }}, {{ URL }}, {{ TEXT }}, {{ CATEGORIES }}, {{ AUTHORS }}, etc.)
  • Caching — file-based (~/.feedforbot/) or in-memory; first run populates the cache silently to avoid flooding the channel
  • Sentry integration — optional error tracking via sentry-sdk
  • Docker ready — multi-arch images on GHCR and Docker Hub
  • Protocol-driven — extend with custom listeners, transports, and cache backends by implementing simple protocols

Installation

Requires Python 3.10+.

pip install feedforbot -U

For the full CLI (Click, structlog, YAML config, Sentry):

pip install "feedforbot[cli]" -U

Quick start

As a library

from feedforbot import Scheduler, TelegramBotTransport, RSSListener

scheduler = Scheduler(
    '*/5 * * * *',
    listener=RSSListener('https://www.debian.org/News/news'),
    transport=TelegramBotTransport(
        token='123456789:AAAAAAAAAA-BBBB-CCCCCCCCCCCC-DDDDDD',
        to='@channel',
    ),
)
scheduler.run()  # blocks, checks the feed every 5 minutes

Async — multiple schedulers

import asyncio

from feedforbot import Scheduler, TelegramBotTransport, RSSListener

schedulers = [
    Scheduler(
        '*/5 * * * *',
        listener=RSSListener('https://www.debian.org/News/news'),
        transport=TelegramBotTransport(
            token='123456789:AAAAAAAAAA-BBBB-CCCCCCCCCCCC-DDDDDD',
            to='@channel',
        ),
    ),
    Scheduler(
        '0 * * * *',
        listener=RSSListener('https://habr.com/ru/rss/all/all/'),
        transport=TelegramBotTransport(
            token='123456789:AAAAAAAAAA-BBBB-CCCCCCCCCCCC-DDDDDD',
            to='@another_channel',
        ),
    ),
]

async def main() -> None:
    await asyncio.gather(*(s.arun() for s in schedulers))

asyncio.run(main())

CLI with YAML config

Create a config.yml:

---
cache:
  type: 'files'
schedulers:
  - rule: '*/5 * * * *'
    listener:
      type: 'rss'
      params:
        url: 'https://habr.com/ru/rss/all/all/?fl=ru'
    transport:
      type: 'telegram_bot'
      params:
        token: '123456789:AAAAAAAAAA-BBBB-CCCCCCCCCCCC-DDDDDD'
        to: '@tmfeed'
        template: |-
          <b>{{ TITLE }}</b> #habr
          {{ ID }}
          <b>Tags</b>: {% for category in CATEGORIES %}{{ category }}{{ ", " if not loop.last else "" }}{% endfor %}
          <b>Author</b>: <a href="https://habr.com/users/{{ AUTHORS[0] }}">{{ AUTHORS[0] }}</a>
  - listener:
      type: 'rss'
      params:
        url: 'http://www.opennet.ru/opennews/opennews_all.rss'
    transport:
      type: 'telegram_bot'
      params:
        token: '123456789:AAAAAAAAAA-BBBB-CCCCCCCCCCCC-DDDDDD'
        to: '@tmfeed'
        disable_web_page_preview: yes
        template: |-
          <b>{{ TITLE }}</b> #opennet
          {{ URL }}

          {{ TEXT }}

Run:

feedforbot --verbose config.yml

On the first run the cache is populated without sending messages, so existing feed entries won't flood the channel.

Config reference

Key Description
cache.type files (persistent, default dir ~/.feedforbot/) or in_memory
cache.params Backend-specific options (e.g. custom path for files)
schedulers[].rule Cron expression (e.g. */5 * * * *)
schedulers[].listener.type rss
schedulers[].listener.params.url Feed URL
schedulers[].transport.type telegram_bot
schedulers[].transport.params.token Telegram Bot API token
schedulers[].transport.params.to Chat ID or @channel name
schedulers[].transport.params.template Jinja2 template string (HTML parse mode)
schedulers[].transport.params.disable_web_page_preview true / false

Template variables

All fields from ArticleModel are available in uppercase:

Variable Description
{{ TITLE }} Entry title
{{ URL }} Entry link
{{ ID }} Unique entry identifier
{{ TEXT }} Entry summary / description
{{ CATEGORIES }} List of tags/categories
{{ AUTHORS }} List of authors

Docker

Images are published to both GHCR and Docker Hub on every release. Tags follow semver: latest, 4, 4.0, 4.0.0.

docker run -v $(pwd)/config.yml:/config.yml \
  ghcr.io/shpaker/feedforbot --verbose /config.yml
docker run -v $(pwd)/config.yml:/config.yml \
  shpaker/feedforbot --verbose /config.yml

The container runs as a non-root user (appuser).

Healthcheck

The CLI includes a built-in HTTP healthcheck server. Pass --healthcheck-port to expose a lightweight endpoint that responds with 200 OK on every request:

feedforbot --healthcheck-port 8080 --verbose config.yml

Useful for container orchestrators (Docker HEALTHCHECK, Kubernetes liveness probes, etc.):

# docker-compose.yml
services:
  feedforbot:
    image: ghcr.io/shpaker/feedforbot
    command: ["--healthcheck-port", "8080", "--verbose", "/config.yml"]
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/"]
      interval: 30s
      timeout: 5s
      retries: 3

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

feedforbot-4.0.0rc6.tar.gz (96.6 kB view details)

Uploaded Source

Built Distribution

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

feedforbot-4.0.0rc6-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file feedforbot-4.0.0rc6.tar.gz.

File metadata

  • Download URL: feedforbot-4.0.0rc6.tar.gz
  • Upload date:
  • Size: 96.6 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 feedforbot-4.0.0rc6.tar.gz
Algorithm Hash digest
SHA256 6e717be78736d5be28dbb4c5fd5bf33e40c18cf99dca4cd212fcb042645d6902
MD5 b68fdc19a8906585943f5313af34293d
BLAKE2b-256 bb4a93f476c33bd7daafcfc4620df222fd4b9a0aa00093f787b71aa30ab8eda5

See more details on using hashes here.

File details

Details for the file feedforbot-4.0.0rc6-py3-none-any.whl.

File metadata

  • Download URL: feedforbot-4.0.0rc6-py3-none-any.whl
  • Upload date:
  • Size: 18.2 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 feedforbot-4.0.0rc6-py3-none-any.whl
Algorithm Hash digest
SHA256 4f58cb64afc33110a0d7369ef498871ec744d0374ee36d5a1bc273da353d098c
MD5 14c08a96bfb5e7c1e9ef163c2e5eaa45
BLAKE2b-256 7dd79cdb643fe6c6472e010b1018ec499250d5beb023f42c9e6cdfef999b1f03

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