/rss-to-telegram-bot

Simple bot for reading posts from rss and

Primary LanguagePHP

RSS to Telegram bot

Small project for scraping RSS feed and repost new messages to Telegram group/channel.

How to use

  1. Clone repo
git clone https://github.com/EvilFreelancer/rss-to-telegram-bot.git
  1. Switch to project root
cd rss-to-telegram-bot
  1. Create .env file from example
cp .env.dist .env
  1. Fix .env parameters, you at least need to add list of RSS feed sources and API token of Telegram-bot

  2. Run the script

php -f rss-to-telegram.php

Example docker-compose.yml

This project already has Dockerfile, so you may build your own docker image and use it.

version: "2.4"

services:

  rss-to-telegram-bot:
    restart: "unless-stopped"
    build:
      context: .
    environment:
      # Timeout in seconds between requests to rss feed
      RSSREADER_TIMEOUT: 600
      # Path to RSS feed cache folder
      RSSREADER_CACHE_DIR: /app/cache
      # Limiting the number of recent posts
      RSSREADER_LIMIT: 50
      # List of comma-separated URLs of RSS sources
      RSSREADER_SOURCES: https://portal1/news/rss/,https://portal2/rss/
      # If you want to show categories as hash-tags
      RSSREADER_SHOW_CATEGORIES_AS_TAGS: false
      # Telegram Channel Name
      TELEGRAM_CHANNEL_NAME: evilfreelancer
      # Telegram Access Token
      TELEGRAM_TOKEN: nnnnnnnnnnnnn:xxxXXXxXxXxXxXXxXxxXxxxxXx
    volumes:
      - ./bot_cache:/app/cache:rw
    logging:
      driver: "json-file"
      options:
        max-size: "50k"

Environment variables

Name Default value Description
RSSREADER_TIMEOUT 3600 (in seconds) Timeout between requests for updates
RSSREADER_CACHE_DIR /tmp/.rssreader_cache Path to directory with cache
RSSREADER_LIMIT 0 (0, empty or not set - unlimited) Limiting the number of recent posts
RSSREADER_SOURCES null List of comma-separated URLs of RSS sources
RSSREADER_SHOW_CATEGORIES_AS_TAGS false If you want to show categories as hash-tags
TELEGRAM_CHANNEL_NAME null Telegram Channel Name
TELEGRAM_TOKEN null Telegram Access Token

Links