Another telegram RSSBot in Node.js
A RSSBot in telegram similar to https://github.com/iovxw/rssbot/. But this time in Node.js.
RSS is parsered using rss-parser
The same as https://github.com/iovxw/rssbot/
/rss - show subscriptions,add raw to show links
/sub - subscribe a RSS: /sub http://example.com/feed.xml
/unsub - unsubscribe a RSS: /unsub http://example.com/feed.xml
/unsubthis - reply a message from a RSS feed to unsubscribe it
/allunsub - unsubscribe all feeds
/export - export subscriptions to opml file
/viewall - view all subscriptions and number of subscribers need to enable in settings
/import - reply this message a opml file to import(in group)
You can add channel id to subscribe a feed for a channel in private chat after add the bot as administrator
for example /sub <channel id > <feed url>
(channel id is startwith @)
You can send a opml file directly to import feed in private chat
use /import
in group
for channel import send a opml file name by channel id with a opml suffix name in private chat for example @myChannel.opml
viewall can only be uesed in private chat
After install docker
- Run
docker pull fengkx/node_rssbot
- Run
docker run --name rssbot -d -v <directory to store database file>:/app/data/ -e RSSBOT_TOKEN=<YOUR_TGBOT_TOKEN> fengkx/node_rssbot
for exmaple docker run --name rssbot -d -v /var/data:/app/data/ -e RSSBOT_TOKEN=123456:abcdef123456-U fengkx/rssbot
- Install Docker
- clone this repository
git clone https://github.com/fengkx/NodeRSSBot.git
- Run
docker build .
then you will get a image id - Run
docker run --name rssbot -d -e RSSBOT_TOKEN=<YOUR_TGBOT_TOKEN> <YOUR_IMAGE_ID>
for example docker run --name rssbot -d -e RSSBOT_TOKEN=123456:abcdef123456-U fd54321bff2
- Node.js and npm installed
- clone this repository
git clone https://github.com/fengkx/NodeRSSBot.git
- Set the
RSSBOT_TOKEN
environment variable or set it in config/index.js - Install dependencies run
npm i
in the root directory of the repository - Run
pm2 start index.js
All setting can be set by either environment variable or in config/index.js
setting | env | default/require | description |
---|---|---|---|
token | RSSBOT_TOKEN | require | telegram bot token |
db_path | RSSBOT_DB_PATH | data/database.db | path to store database file |
lang | RSSBOT_LANG | zh-cn | language |
item_num | RSSBOT_ITEM_NUM | 10 | send the laset number of item |
fetch_gap | RSSBOT_FETCH_GAP | 5m | fetch gap |
notify_error_count | NOTIFY_ERR_COUNT | 5 | error count when it will notfiy |
view_all | RSSBOT_VIEW_ALL | false | enable or not |
UA | RSSBOT_UA | 'Mozilla/5.0 NodeRSSBot(https://github.com/fengkx/NodeRSSBot)' | user-agent of requrest |
proxy.protocol | PROXY_PROTOCOL | null | proxy protocol http/https/socks |
proxy.host | PROXY_HOST | null | proxy host |
proxy.port | PROXY_PORT | null | proxy port |
fetch_gap can be setting in how many minutes or hours。m for minute, h for hour
for example 5m means every 5 minutes, 1h means every 1 hour
translate the file in i18n
in the another yaml and make a pull request (๑•̀ㅂ•́)و✧
set lang
setting using one of the following language
- en English
- zh-cn Chinese
- es-es Spanish provided by @NPueyo
又是一个 telegram RSS Bot 不过这次用的是 Node.js
模仿https://github.com/iovxw/rssbot/ 做的一个 RSSBot,用telegraf
首先感谢 iovxw 的 RSSBot 一直用的很好
做这个东西只是为了,配置起来更方便一些不用安装 Rust 的工具链和编译
RSS 解析用的是 rss-parser,它支持的就支持
基本与 https://github.com/iovxw/rssbot/一致
/rss - 显示订阅列表,加 `raw`显示链接
/sub - 订阅 RSS: /sub http://example.com/feed.xml
/unsub - 退订 RSS: /unsub http://example.com/feed.xml
/unsubthis - 回复一个 RSS 发来的消息退订该 RSS
/allunsub - 退订所有源
/export - 导出订阅到opml文件
/viewall - 查看所有订阅和订阅人数 需要在设置中打开
/import - 回复此消息 opml 文件导入订阅(群组)
把 bot 设为频道管理员并正确配置权限后,可通过私聊在/sub
后加上频道 id 来在频道中订阅 feed
例如 /sub <频道 id > <feed url>
(频道 id 是@打头的)
直接发送 opml 文件,可以导入 RSS 源
频道导入需要将文件名改成频道 id 并且以 opml 作为后缀在私聊中发送 例如 @myChannel.opml
viewall 只能在私聊中使用
安装好了 docker 之后
- 运行
docker pull fengkx/node_rssbot
- 运行
docker run --name rssbot -d -v <directory to store database file>:/app/data/ -e RSSBOT_TOKEN=<YOUR_TGBOT_TOKEN> fengkx/node_rssbot
例如 docker run --name rssbot -d -v /var/data:/app/data/ -e RSSBOT_TOKEN=123456:abcdef123456-U fengkx/rssbot
- 安装 Docker
- 克隆仓库
git clone https://github.com/fengkx/NodeRSSBot.git
- 构建 docker image
docker build .
then you will get a image id - 运行
docker run --name rssbot -d -e RSSBOT_TOKEN=<YOUR_TGBOT_TOKEN> <YOUR_IMAGE_ID>
例如 docker run --name rssbot -d -e RSSBOT_TOKEN=123456:abcdef123456-U fd54321bff2
- 首先要有 Node.js 和 npm 或 yarn
- 克隆仓库
git clone https://github.com/fengkx/NodeRSSBot.git
- 设置
RSSBOT_TOKEN
环境变量,或者直接在config/index.js
中修改 - 安装依赖 在仓库根目录运行
npm i
- 推荐用
pm2
守护进程pm2 start index.js
如果没有安装pm2
就先安装npm i -g pm2
- export 命令
- 代理
- unit test
所有配置项都可以用环境变量或者直接在 config/index.js
中修改
设置项 | 环境变量 | 默认/必填 | 描述 |
---|---|---|---|
token | RSSBOT_TOKEN | require | telegram bot token |
db_path | RSSBOT_DB_PATH | data/database.db | 数据库文件路径 |
lang | RSSBOT_LANG | zh-cn | 语言 |
item_num | RSSBOT_ITEM_NUM | 10 | 发送最新几条信息 |
fetch_gap | RSSBOT_FETCH_GAP | 5m | 抓取间隔 |
notify_error_count | NOTIFY_ERR_COUNT | 5 | 发出通知的错误次数 |
view_all | RSSBOT_VIEW_ALL | false | 是否开启 |
UA | RSSBOT_UA | 'Mozilla/5.0 NodeRSSBot(https://github.com/fengkx/NodeRSSBot)' | 请求的 user-agent |
proxy.protocool | PROXY_PROTOCOL | null | 代理协议 http/https/socks |
proxy.host | PROXY_HOST | null | 代理地址 |
proxy.port | PROXY_PORT | null | 代理端口 |
语言可以设置为 zh-cn
or en
时间间隔可设置为每多少分钟或多少小时。m 表示分钟, h 表示小时
例如 5m 表示每 5 分钟, 1h 表示每 1 小时
在 i18n
目录翻译 yaml 文件然后来个 ·pr· (๑•̀ㅂ•́)و✧
以下任意一个语言作为lang
配置项
- en English
- zh-cn 中文
- es-es Spanish provided by @NPueyo