npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rss-telegram-bot

v1.7.0

Published

RSSBot 是一个能帮你订阅 RSSHub 的 Telegram Bot

Downloads

17

Readme

RSSBot

RSSBot 是一个能帮你保存链接和订阅 RSSHub 的 Telegram Bot。

你是否对订阅源的质量要求很严格? 你是否会一次集中收集大量的订阅源?觉得RSSAid不适合大量收集订阅源的使用场景? 不想有乍看很好当场订阅过后细看却很烂的订阅源污染自己的数据库? 看到优质订阅源没空细看想找个地方暂存留待以后再确定要不要订阅?

这个小工具会保存你发送给它的所有链接,并辅助你在碎片时间完成订阅。 一次发一大堆的链接也是可以的哦。 不错过任何一个精彩的信息源,不放过任何一个垃圾的信息源。

Use it

Run it

git clone https://github.com/yindaheng98/RSSBot
cd RSSBot
export VALID_USERNAME=<your Telegram username, RSSBot will only reply messages sent from this username>
export TELEGRAM_BOT_TOKEN=<your telegram bot token>
export RSS_DRIVER=ttrss
export RSS_HOST=<your ttrss host>
export RSS_USERNAME=<your ttrss username>
export RSS_PASSWORD=<your ttrss password>
npm run start

Or run it via docker

docker run --name rssbot --rm -it \
    -v ./rssbot/db:/app/db \
    -e VALID_USERNAME=<your Telegram username, RSSBot will only reply messages sent from this username> \
    -e TELEGRAM_BOT_TOKEN=<your telegram bot token> \
    -e RSS_DRIVER=ttrss \
    -e RSS_HOST=<your ttrss host> \
    -e RSS_USERNAME=<your ttrss username> \
    -e RSS_PASSWORD=<your ttrss password> \
    yindaheng98/rssbot

Send a URL to your RSSBot e.g. https://twitter.com/DIYgod:

The RSSBot will parse the URL and fetch the category list from your specified rss driver (e.g. RSS_DRIVER=ttrss). Then you will receive a reply, and you can select a category:

Select a category and send the message (e.g. select the category "Uncategorized"):

The RSSBot will convert the URL to an RSSHub link and call the API (e.g. TTRSS API) to subscribe to the RSSHub link.

Features: Save your URL

RSSBot has a sample database to store all the URLs you sent. Only when RSSBot successfully subscribes to an RSSHub link, the related URL will be deleted from the database.

RSSBot will randomly select a stored URL and send it to remind you. You can config the frequency with the environment variable UNSUB_CHECK and UNSUB_CHECK_CRON. See config.js for more detail.

Config

All config variables are read from environments. See config.js.

Add custom functions

Install RSSBot as a package:

npm install rss-telegram-bot

Write your app:

const { bot, rss, user } = require('rss-telegram-bot');

function getEHLink(tag) {
    let feeds = [];
    for (let url_format of config.eh_feed_formats) {
        feeds.push(util.format(url_format, encodeURIComponent(tag)));
    }
    return feeds
}

async function sendSubscribe(msg, category_id, tag) {
    const chatId = msg.chat.id;
    const msgId = msg.message_id;
    const category_title = await rss.getCategoryTitle(category_id);
    for (let feed_url of getEHLink(tag)) {
        logger.info(`Subscribing: ${feed_url}`);
        if (('' + category_id) === await rss.isSubscribed(feed_url)) {
            continue;
        }
        const { ok, err } = await rss.subscribeToFeed(category_id, feed_url);
        if (!ok) {
            const inline_keyboards = [[{
                text: 'Retry it',
                switch_inline_query_current_chat: `/subscribe_eh ${category_id} ${tag}`
            }]];
            bot.sendMessage(chatId, `Cannot subscribed to ${category_title}: ${err}`, {
                reply_to_message_id: msgId,
                reply_markup: {
                    inline_keyboard: inline_keyboards
                }
            });
            return;
        }
    }
    bot.sendMessage(chatId, `Subscribed to ${category_title}: ${tag}`, {
        reply_to_message_id: msgId
    });
}

bot.onQuery(/^\/subscribe_eh ([0-9]+) (artist:"[A-Za-z0-9 ]+\$")$/, async (msg, match) => {
    const category_id = parseInt(match[1]);
    const tag = match[2];
    sendSubscribe(msg, category_id, tag);
});

API

const { bot, rss, user } = require('rss-telegram-bot');

TBD