diff --git a/docs/game.md b/docs/game.md index 5f30ec9e7..c9400f742 100644 --- a/docs/game.md +++ b/docs/game.md @@ -771,7 +771,7 @@ Example:`https://www.iyingdi.com/tz/people/55547` ,id 是 `55547` ## 英雄联盟 -### 新闻中心 +### 国服新闻 @@ -781,6 +781,16 @@ Example:`https://www.iyingdi.com/tz/people/55547` ,id 是 `55547` +### 台服新闻 + + + +| 活动 | 资讯 | 系统 | 电竞 | 版本资讯 | 战棋资讯 | +| ----- | ---- | ------ | ------ | ----- | -------- | +| event | info | system | esport | patch | TFTpatch | + + + ## 游民星空 ### 游民星空今日推荐 diff --git a/lib/v2/loltw/maintainer.js b/lib/v2/loltw/maintainer.js new file mode 100644 index 000000000..d153028a5 --- /dev/null +++ b/lib/v2/loltw/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/news/:category?': ['hoilc'], +}; diff --git a/lib/v2/loltw/news.js b/lib/v2/loltw/news.js new file mode 100644 index 000000000..00c54d79e --- /dev/null +++ b/lib/v2/loltw/news.js @@ -0,0 +1,36 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const { art } = require('@/utils/render'); +const path = require('path'); + +module.exports = async (ctx) => { + const category = ctx.params.category ?? ''; + + const baseUrl = 'https://lol.garena.tw'; + + const response = await got(`${baseUrl}/api/news/search?category=${category}`); + + const list = response.data.data.news.map((item) => ({ + guid: item.id, + title: item.title, + author: 'Garena', + link: `${baseUrl}/news/articles/${item.id}`, + pubDate: parseDate(item.updated_at * 1000), + })); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got(`${baseUrl}/api/news/detail?news_id=${item.guid}`); + item.description = art(path.join(__dirname, 'templates/news.art'), detailResponse.data.data.news_detail); + return item; + }) + ) + ); + + ctx.state.data = { + title: '英雄联盟 - 台服新闻', + link: category ? `${baseUrl}/news/${category}` : `${baseUrl}/news`, + item: items, + }; +}; diff --git a/lib/v2/loltw/radar.js b/lib/v2/loltw/radar.js new file mode 100644 index 000000000..c9613aeff --- /dev/null +++ b/lib/v2/loltw/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'garena.tw': { + _name: 'Garena', + lol: [ + { + title: '英雄联盟台服新闻', + docs: 'https://docs.rsshub.app/game.html#ying-xiong-lian-meng-tai-fu-xin-wen', + source: ['/news/:category', '/news'], + target: (params) => '/loltw/news/' + (params.category || ''), + }, + ], + }, +}; diff --git a/lib/v2/loltw/router.js b/lib/v2/loltw/router.js new file mode 100644 index 000000000..dae94fc37 --- /dev/null +++ b/lib/v2/loltw/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/news/:category?', require('./news')); +}; diff --git a/lib/v2/loltw/templates/news.art b/lib/v2/loltw/templates/news.art new file mode 100644 index 000000000..d009bbd37 --- /dev/null +++ b/lib/v2/loltw/templates/news.art @@ -0,0 +1,6 @@ +
+{{if img}} + +{{/if}} +{{@ content }} +