diff --git a/README.md b/README.md index a8c9a888339..0ce2af06676 100644 --- a/README.md +++ b/README.md @@ -121,8 +121,9 @@ RSS 解析用的是 [rss-parser](https://www.npmjs.com/package/rss-parser),它 1. 推荐用 `pm2` 守护进程 `pm2 start index.js` 如果没有安装`pm2` 就先安装 `npm i -g pm2` # TODO -1. export 命令 -1. 代理 +- [x] export 命令 +- 代理 +- unit test # 配置项 **所有配置项都可以用环境变量或者直接在 `config/index.js`中修改** diff --git a/index.js b/index.js index 520926dbf7d..8d58b829f7c 100644 --- a/index.js +++ b/index.js @@ -91,7 +91,7 @@ bot.action('UNSUB_ALL_YES', RSS.unsubAll, async (ctx, next) => { const cb = ctx.callbackQuery; - const res = await ctx.telegram.answerCbQuery(); + const res = await ctx.telegram.answerCbQuery(cb.id); } ); diff --git a/utils/fetch.js b/utils/fetch.js index 70aa5f79875..95cc484b4f5 100644 --- a/utils/fetch.js +++ b/utils/fetch.js @@ -3,9 +3,15 @@ const Parser = require('rss-parser'); const config = require('../config'); const hashFeed = require('../utils/hashFeed'); const _pick = require('lodash.pick'); -const {getAllFeeds, updateHashList, failAttempt, getFeedByUrl} = require('../proxies/rssFeed'); const schedule = require('node-schedule'); const logger = require('./logger'); +const { + getAllFeeds, + updateHashList, + failAttempt, + getFeedByUrl, + resetErrorCount +} = require('../proxies/rssFeed'); const fetch = async (feedUrl) => { try { @@ -14,14 +20,14 @@ const fetch = async (feedUrl) => { const parser = new Parser(); const feed = await parser.parseString(res.data); const items = feed.items.slice(0, config.item_num); - const hashList = await Promise.all( + await resetErrorCount(feedUrl); + return await Promise.all( items.map(async item => { return _pick(item, ['link', 'title', 'content']); }) ); - return hashList; } catch (e) { - failAttempt(feedUrl); + await failAttempt(feedUrl); getFeedByUrl(feedUrl).then(feed => { if (feed.error_count >= 5) { logger.info(feed, 'ERROR_MANY_TIME')