Skip to content

Commit be7e8f9

Browse files
committed
pre-commit-config
1 parent cb832ad commit be7e8f9

File tree

4 files changed

+115
-60
lines changed

4 files changed

+115
-60
lines changed

.prettierrc

-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@
77
"trailingComma": "none",
88
"bracketSpacing": true,
99
"arrowParens": "always",
10-
"parser": "babylon"
1110
}

README.md

+67-48
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# NodeRSSBot
2+
23
Another telegram RSSBot in Node.js
34

45
A RSSBot in telegram similar to [https://github.com/iovxw/rssbot/](https://github.com/iovxw/rssbot/). But this time in Node.js.
56

67
# Support version
8+
79
RSS is parsered using [rss-parser](https://www.npmjs.com/package/rss-parser)
810

911
# Usage
12+
1013
The same as [https://github.com/iovxw/rssbot/](https://github.com/iovxw/rssbot/)
1114

1215
```
@@ -19,75 +22,85 @@ The same as [https://github.com/iovxw/rssbot/](https://github.com/iovxw/rssbot/)
1922
/viewall - view all subscriptions and number of subscribers need to enable in settings
2023
```
2124

22-
You can add channel id to subscribe a feed for a channel in private chat after add the bot as administrator
25+
You can add channel id to subscribe a feed for a channel in private chat after add the bot as administrator
2326
for example `/sub <channel id > <feed url>` (channel id is startwith @)
24-
25-
You can send a opml file directly to import feed
26-
viewall can only be uesed in private chat
27+
28+
You can send a opml file directly to import feed
29+
viewall can only be uesed in private chat
2730

2831
# Depolyment
32+
2933
## Docker
34+
3035
### Use autobuild docker image
36+
3137
After install docker
38+
3239
1. Run`docker pull fengkx/node_rssbot`
33-
1. Run `docker run --name rssbot -d -v <directory to store database file>:/app/data/ -e RSSBOT_TOKEN=<YOUR_TGBOT_TOKEN> fengkx/node_rssbot`
40+
1. Run `docker run --name rssbot -d -v <directory to store database file>:/app/data/ -e RSSBOT_TOKEN=<YOUR_TGBOT_TOKEN> fengkx/node_rssbot`
3441

35-
for exmaple `docker run --name rssbot -d -v /var/data:/app/data/ -e RSSBOT_TOKEN=123456:abcdef123456-U fengkx/rssbot`
42+
for exmaple `docker run --name rssbot -d -v /var/data:/app/data/ -e RSSBOT_TOKEN=123456:abcdef123456-U fengkx/rssbot`
3643

3744
### Build docker locally
45+
3846
1. Install Docker
3947
1. clone this repository `git clone https://github.com/fengkx/NodeRSSBot.git`
4048
1. Run `docker build .` then you will get a image id
41-
1. Run`docker run --name rssbot -d -e RSSBOT_TOKEN=<YOUR_TGBOT_TOKEN> <YOUR_IMAGE_ID>`
49+
1. Run`docker run --name rssbot -d -e RSSBOT_TOKEN=<YOUR_TGBOT_TOKEN> <YOUR_IMAGE_ID>`
4250

43-
for example `docker run --name rssbot -d -e RSSBOT_TOKEN=123456:abcdef123456-U fd54321bff2`
51+
for example `docker run --name rssbot -d -e RSSBOT_TOKEN=123456:abcdef123456-U fd54321bff2`
4452

4553
## PM2
54+
4655
1. Node.js and npm installed
4756
1. clone this repository `git clone https://github.com/fengkx/NodeRSSBot.git`
4857
1. Set the `RSSBOT_TOKEN` environment variable or set it in config/index.js
4958
1. Install dependencies run `npm i` in the root directory of the repository
5059
1. Run `pm2 start index.js`
5160

5261
# Setting
53-
**All setting can be set by either environment variable or in `config/index.js`**
5462

63+
**All setting can be set by either environment variable or in `config/index.js`**
5564

56-
| setting | env | default/require | description |
57-
| ------------------ | ---------------- | ---------------- | ---------------------------------------- |
58-
| token | RSSBOT_TOKEN | **require** | [telegram bot token](https://core.telegram.org/bots#3-how-do-i-create-a-bot) |
59-
| db_path | RSSBOT_DB_PATH | data/database.db | path to store database file |
60-
| lang | RSSBOT_LANG | zh-cn | language |
61-
| item_num | RSSBOT_ITEM_NUM | 10 | send the laset number of item |
62-
| fetch_gap | RSSBOT_FETCH_GAP | 5m | fetch gap |
63-
| notify_error_count | NOTIFY_ERR_COUNT | 5 | error count when it will notfiy |
64-
| view_all | RSSBOT_VIEW_ALL | false | enable or not |
65-
| UA | RSSBOT_UA | 'Mozilla/5.0 NodeRSSBot(https://github.com/fengkx/NodeRSSBot)' | user-agent of requrest|
65+
| setting | env | default/require | description |
66+
| ------------------ | ---------------- | -------------------------------------------------------------- | ---------------------------------------------------------------------------- |
67+
| token | RSSBOT_TOKEN | **require** | [telegram bot token](https://core.telegram.org/bots#3-how-do-i-create-a-bot) |
68+
| db_path | RSSBOT_DB_PATH | data/database.db | path to store database file |
69+
| lang | RSSBOT_LANG | zh-cn | language |
70+
| item_num | RSSBOT_ITEM_NUM | 10 | send the laset number of item |
71+
| fetch_gap | RSSBOT_FETCH_GAP | 5m | fetch gap |
72+
| notify_error_count | NOTIFY_ERR_COUNT | 5 | error count when it will notfiy |
73+
| view_all | RSSBOT_VIEW_ALL | false | enable or not |
74+
| UA | RSSBOT_UA | 'Mozilla/5.0 NodeRSSBot(https://github.com/fengkx/NodeRSSBot)' | user-agent of requrest |
6675

67-
language can be setting in `zh-cn` or `en`
76+
language can be setting in `zh-cn` or `en`
6877

6978
fetch_gap can be setting in how many minutes or hours。m for minute, h for hour
70-
79+
7180
for example 5m means every 5 minutes, 1h means every 1 hour
7281

7382
# i18n
7483

7584
translate the file in `i18n` in the another yaml and make a pull request (๑•̀ㅂ•́)و✧
7685

77-
---------------
86+
---
87+
7888
# 中文文档
7989

8090
# NodeRSSBot
91+
8192
又是一个 telegram RSS Bot 不过这次用的是 Node.js
8293

83-
模仿[https://github.com/iovxw/rssbot/](https://github.com/iovxw/rssbot/) 做的一个RSSBot,用[telegraf](https://www.npmjs.com/package/telegraf)
84-
首先感谢 iovxw 的 RSSBot 一直用的很好
85-
做这个东西只是为了,配置起来更方便一些不用安装Rust的工具链和编译
94+
模仿[https://github.com/iovxw/rssbot/](https://github.com/iovxw/rssbot/) 做的一个 RSSBot,用[telegraf](https://www.npmjs.com/package/telegraf)
95+
首先感谢 iovxw 的 RSSBot 一直用的很好
96+
做这个东西只是为了,配置起来更方便一些不用安装 Rust 的工具链和编译
8697

8798
# 支持的版本
99+
88100
RSS 解析用的是 [rss-parser](https://www.npmjs.com/package/rss-parser),它支持的就支持
89101

90102
# Usage
103+
91104
基本与 [https://github.com/iovxw/rssbot/](https://github.com/iovxw/rssbot/)一致
92105

93106
```
@@ -99,30 +112,34 @@ RSS 解析用的是 [rss-parser](https://www.npmjs.com/package/rss-parser),它
99112
/export - 导出订阅到opml文件
100113
/viewall - 查看所有订阅和订阅人数 需要在设置中打开
101114
```
115+
102116
把 bot 设为频道管理员并正确配置权限后,可通过私聊在`/sub`后加上频道 id 来在频道中订阅 feed
103117
例如 `/sub <频道 id > <feed url>` (频道 id 是@打头的)
104118

105-
直接发送opml文件,可以导入RSS源
119+
直接发送 opml 文件,可以导入 RSS 源
106120
viewall 只能在私聊中使用
107121

108-
109122
# 部署
123+
110124
## Docker
111125

112126
### 使用自动构建的 docker image
127+
113128
安装好了 docker 之后
129+
114130
1. 运行`docker pull fengkx/node_rssbot`
115-
1. 运行 `docker run --name rssbot -d -v <directory to store database file>:/app/data/ -e RSSBOT_TOKEN=<YOUR_TGBOT_TOKEN> fengkx/node_rssbot`
131+
1. 运行 `docker run --name rssbot -d -v <directory to store database file>:/app/data/ -e RSSBOT_TOKEN=<YOUR_TGBOT_TOKEN> fengkx/node_rssbot`
116132

117-
例如 `docker run --name rssbot -d -v /var/data:/app/data/ -e RSSBOT_TOKEN=123456:abcdef123456-U fengkx/rssbot`
133+
例如 `docker run --name rssbot -d -v /var/data:/app/data/ -e RSSBOT_TOKEN=123456:abcdef123456-U fengkx/rssbot`
118134

119135
### 本地构建
136+
120137
1. 安装 Docker
121138
1. 克隆仓库 `git clone https://github.com/fengkx/NodeRSSBot.git`
122139
1. 构建 docker image `docker build .` then you will get a image id
123-
1. 运行 `docker run --name rssbot -d -e RSSBOT_TOKEN=<YOUR_TGBOT_TOKEN> <YOUR_IMAGE_ID>`
140+
1. 运行 `docker run --name rssbot -d -e RSSBOT_TOKEN=<YOUR_TGBOT_TOKEN> <YOUR_IMAGE_ID>`
124141

125-
例如 `docker run --name rssbot -d -e RSSBOT_TOKEN=123456:abcdef123456-U fd54321bff2`
142+
例如 `docker run --name rssbot -d -e RSSBOT_TOKEN=123456:abcdef123456-U fd54321bff2`
126143

127144
## PM2
128145

@@ -133,29 +150,31 @@ viewall 只能在私聊中使用
133150
1. 推荐用 `pm2` 守护进程 `pm2 start index.js` 如果没有安装`pm2` 就先安装 `npm i -g pm2`
134151

135152
# TODO
136-
- [x] export 命令
137-
- 代理
138-
- unit test
153+
154+
- [x] export 命令
155+
- 代理
156+
- unit test
139157

140158
# 配置项
141-
**所有配置项都可以用环境变量或者直接在 `config/index.js`中修改**
142159

160+
**所有配置项都可以用环境变量或者直接在 `config/index.js`中修改**
143161

144-
| 设置项 | 环境变量 | 默认/必填 | 描述 |
145-
| ------------------ | ---------------- | ---------------- | ---------------------------------------- |
146-
| token | RSSBOT_TOKEN | **require** | [telegram bot token](https://core.telegram.org/bots#3-how-do-i-create-a-bot) |
147-
| db_path | RSSBOT_DB_PATH | data/database.db | 数据库文件路径 |
148-
| lang | RSSBOT_LANG | zh-cn | 语言 |
149-
| item_num | RSSBOT_ITEM_NUM | 10 | 发送最新几条信息 |
150-
| fetch_gap | RSSBOT_FETCH_GAP | 5m | 抓取间隔 |
151-
| notify_error_count | NOTIFY_ERR_COUNT | 5 | 发出通知的错误次数 |
152-
| view_all | RSSBOT_VIEW_ALL | false | 是否开启 |
153-
| UA | RSSBOT_UA | 'Mozilla/5.0 NodeRSSBot(https://github.com/fengkx/NodeRSSBot)' | 请求的 user-agent |
162+
| 设置项 | 环境变量 | 默认/必填 | 描述 |
163+
| ------------------ | ---------------- | -------------------------------------------------------------- | ---------------------------------------------------------------------------- |
164+
| token | RSSBOT_TOKEN | **require** | [telegram bot token](https://core.telegram.org/bots#3-how-do-i-create-a-bot) |
165+
| db_path | RSSBOT_DB_PATH | data/database.db | 数据库文件路径 |
166+
| lang | RSSBOT_LANG | zh-cn | 语言 |
167+
| item_num | RSSBOT_ITEM_NUM | 10 | 发送最新几条信息 |
168+
| fetch_gap | RSSBOT_FETCH_GAP | 5m | 抓取间隔 |
169+
| notify_error_count | NOTIFY_ERR_COUNT | 5 | 发出通知的错误次数 |
170+
| view_all | RSSBOT_VIEW_ALL | false | 是否开启 |
171+
| UA | RSSBOT_UA | 'Mozilla/5.0 NodeRSSBot(https://github.com/fengkx/NodeRSSBot)' | 请求的 user-agent |
154172

155173
语言可以设置为 `zh-cn` or `en`
156-
时间间隔可设置为每多少分钟或多少小时。m 表示分钟, h表示小时
174+
时间间隔可设置为每多少分钟或多少小时。m 表示分钟, h 表示小时
157175

158-
例如 5m 表示每5分钟, 1h 表示每1小时
176+
例如 5m 表示每 5 分钟, 1h 表示每 1 小时
159177

160178
# i18n
161-
`i18n`目录翻译yaml文件然后来个 ·pr· (๑•̀ㅂ•́)و✧
179+
180+
`i18n`目录翻译 yaml 文件然后来个 ·pr· (๑•̀ㅂ•́)و✧

package-lock.json

+43
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-11
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,12 @@
77
"start": "node index",
88
"dev": "proxychains -q node $NODE_DEBUG_OPTION index",
99
"test": "echo \"Error: no test specified\" && exit 1",
10-
"format": "prettier \"**/*.js\" --write",
11-
"pre-commit": "lint-staged"
10+
"format": "eslint \"**/*.js\" --fix && prettier \"**/*.{js,json,md}\" --write",
11+
"lint": "eslint \"**/*.js\" && prettier-check \"**/*.{js,json,md}\""
1212
},
1313
"pre-commit": [
14-
"pre-commit"
14+
"lint"
1515
],
16-
"lint-staged": {
17-
"*.js": [
18-
"eslint --fix",
19-
"prettier --write",
20-
"git add"
21-
]
22-
},
2316
"repository": {
2417
"type": "git",
2518
"url": "git+https://github.com/fengkx/NodeRSSBot.git"
@@ -49,6 +42,7 @@
4942
"devDependencies": {
5043
"lint-staged": "^8.1.0",
5144
"pre-commit": "^1.2.2",
52-
"prettier": "^1.15.3"
45+
"prettier": "^1.15.3",
46+
"prettier-check": "^2.0.0"
5347
}
5448
}

0 commit comments

Comments
 (0)