Socket
Socket
Sign inDemoInstall

telegram-rss-feed

Package Overview
Dependencies
159
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    telegram-rss-feed

Ever wanted to have a bot that posts new RSS feed entries to a channel or group on telegram? Well, here you go.


Version published
Weekly downloads
1
Maintainers
1
Created
Weekly downloads
 

Readme

Source

NodeJS Telegram RSS Feed Channel Bot

Ever wanted to have a bot that posts new RSS feed entries to a channel or group on telegram? Well, here you go.

How to use

  1. setup a bot from telegram's @botfather accounts
  2. check the build arguments the Dockerfile accepts and edit to your demands
  3. setup a cronjob on your machine/server to run the docker container every 120 minutes or so
  4. enjoy the news on telegram 🤗
  • Run using Docker
  • Concepts / Good to know

Dependencies

let's go easy on the dependencies, shall we?

for all of the dev dependencies, see the package.json, but the most important ones are:

Run using Docker

run (in a cron job maybe?)

docker run --rm \
  -v /path/to/telegram-rss-feed/db:/app/db \
  -e TELEGRAM_API_KEY=12345666:abcdefg \
  -e TELEGRAM_CHANNEL_OR_GROUP=your-channel-or-group \
  -e FEED_URL=https://test.test/awesomefeed.rss \
  ghcr.io/simonneutert/telegram-rss-feed:main

Need to build it yourself?

$ docker build . \
  --build-arg telegram_key=THIS123MY:TELEGRAMKEY \
  --build-arg telegram_channel_or_group=@channel_or_groupnumber_on_telegram \
  --build-arg feed_url=https://www.rss-feed.test/feed \
  -t mytelegramrssbot
$ docker run --rm \
  -v /path/to/telegram-rss-feed/db:/app/db \
  mytelegramrssbot

No Docker?

Make sure to set the ENV variables just as you need it.

$ mkdir mytelegramrssbot
$ cd mytelegramrssbot
$ npm init
$ npm install telegram-rss-feed --save
$ touch index.js
// content of index.js
const { Db } = require("telegram-rss-feed/lib/db");
const { parseFeed } = require("telegram-rss-feed/lib/parseFeed");
const { sendMessage } = require("telegram-rss-feed/lib/sendMessage");

Db.sync() // { force: true } will be useful if you need to start from scratch
  .then(() => {});

/**
 * this function auto calls itself in an async fashion
 */
(async () => {
  // you can also pass a custom function to handle the message sending
  await parseFeed(
    process.env.FEED_URL,
    sendMessage, {
      telegramApiKey: "12345666:abcdefg",
      telegramChannelOrGroup: "@your-channel-or-group",
    }
  );
})();

Then run it with:

$ node index.js

Concepts / Good to know

  • docker host volume persistant sqlite database that uses a unique constraint, to not send duplicates into the channel.
  • public channel messaging, but your bot needs admin privileges
  • will work out-of-the-box with any standard compliant modern rss feed supported by rss-parser on npm

FAQs

Last updated on 15 Jan 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc