Skip to content

Apocalypsor/Formatted-RSS-to-Telegram

Repository files navigation

Formatted RSS to Telegram

A highly customizable, production-ready RSS to Telegram bot with persistent message queue, rate limiting, and advanced content processing capabilities.

sample

Features

Core Features

  • Persistent Message Queue - SQLite-backed queue with automatic crash recovery
  • Rate Limiting - Sequential message processing with configurable delay (p-queue)
  • First Run Detection - Silently saves history on initial setup to avoid flooding
  • Queue Monitoring - Track pending task count in real time
  • Auto Cleanup - Periodic cleanup of completed tasks and expired history

Content Processing

  • Media Embedding - Automatic image/video extraction from RSS content
  • Template Engine - Nunjucks-powered message templates
  • Content Filtering - Regex-based include/exclude filters with remote URL support
  • Remote Filter Lists - Fetch filter patterns from URLs with optional function transforms
  • Content Rules - Transform RSS fields with regex or custom functions

Network & Proxy

  • Proxy Support - HTTP/HTTPS proxy with authentication (via Bun native fetch)
  • Cloudflare Bypass - FlareSolverr integration for protected feeds
  • Intranet Detection - Automatic proxy bypass for local network feeds

Monitoring & Reliability

  • RSS Monitoring - Telegram notifications for invalid/expired RSS links
  • Structured Logging - Winston-based logging with daily rotation
  • Database Persistence - All tasks and history stored in SQLite
  • Type Safety - Full TypeScript with Zod schema validation

Quick Start

Docker (Recommended)

  1. Install Docker

  2. Create docker-compose.yaml:

    services:
      fr2t:
        image: ghcr.io/apocalypsor/fr2t
        container_name: fr2t
        restart: always
        volumes:
          - ./data:/app/config
          - ./logs:/app/logs
  3. Configure RSS and Bot:

  4. Start the service:

    docker-compose up -d

Local Development

# Install Bun (if not installed)
curl -fsSL https://bun.sh/install | bash

# Install dependencies
bun install

# Start development server with hot reload
bun run dev

# Run production
bun start

Configuration

Bot Configuration (config.yaml)

# Cleanup interval (days)
expireTime: 30

# RSS check interval (minutes)
interval: 10

# User agent for RSS requests
userAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36

# FlareSolverr endpoint (optional)
flaresolverr: http://127.0.0.1:8191/

# Telegram chat ID for RSS monitoring notifications (optional)
notifyTelegramChatId: 111111111

# Proxy configuration (optional)
proxy:
  enabled: true
  protocol: http # http or https
  host: 127.0.0.1
  port: 1080
  auth:
    username: user
    password: pass

# Telegram bot configuration (required)
telegram:
  - name: default
    token: YOUR_BOT_TOKEN
    chatId: YOUR_CHAT_ID
    parseMode: MarkdownV2 # Markdown or MarkdownV2
    disableNotification: false
    disableWebPagePreview: false

RSS Configuration (rss.yaml)

rss:
  - name: GitHub Commits
    url: https://github.com/user/repo/commits.atom
    sendTo: default # or list: [bot1, bot2]

    # Optional settings
    disableNotification: false
    disableWebPagePreview: false
    fullText: true
    embedMedia: true
    embedMediaExclude:
      - https://example.com/.+

    # Content transformation rules
    rules:
      - obj: title
        type: regex # or func
        matcher: ^(\[.+?\])?(.+?)$
        dest: tag

      - obj: content
        type: func
        matcher: |
          return obj.replace(/pattern/, 'replacement');
        dest: processed_content

    # Content filters
    filters:
      # Static regex filter
      - obj: title
        type: in # include only matching
        matcher: important

      - obj: content
        type: out # exclude matching
        matcher: spam|ads

      # Remote filter: fetch URL content as regex
      - obj: author
        type: out
        matcher:
          url: https://example.com/blocklist.txt

      # Remote filter with function transform
      - obj: author
        type: out
        matcher:
          url: https://example.com/blocklist.json
          func: |
            const list = JSON.parse(data);
            return list.users.map(u => u.username).join('|');

    # Message template (Nunjucks)
    text: |
      **{{ title }}**

      {{ content }}

      [Read more]({{ link }})

      _Tags: {{ tag }}_

Available Template Variables

From RSS feed (via rss-parser):

  • title, link, content, contentSnippet
  • author, pubDate, guid
  • Any custom fields from your RSS feed

Custom variables:

  • rss_name - Name of the RSS feed
  • rss_url - URL of the RSS feed
  • Any fields created by rules (e.g., tag, processed_content)

License

Apache-2.0 License - see LICENSE for details.

Acknowledgments

About

Highly customizable RSS to Telegram

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors