diff --git a/docs/forecast.md b/docs/forecast.md index 15e22e087..cd0170a48 100644 --- a/docs/forecast.md +++ b/docs/forecast.md @@ -171,6 +171,14 @@ pageClass: routes +### 深圳市 + + + +可能仅限中国大陆服务器访问,以实际情况为准。 + + + ## 香港天文台 ### Current Weather Report diff --git a/lib/v2/tingshuitz/maintainer.js b/lib/v2/tingshuitz/maintainer.js index 24e7a67ac..0c3980247 100644 --- a/lib/v2/tingshuitz/maintainer.js +++ b/lib/v2/tingshuitz/maintainer.js @@ -5,6 +5,7 @@ module.exports = { '/guangzhou': ['xyqfer'], '/hangzhou': ['znhocn'], '/nanjing': ['ocleo1'], + '/shenzhen': ['lilPiper'], '/wuhan': ['MoonBegonia'], '/xian': ['ciaranchen'], '/xiaoshan': ['znhocn'], diff --git a/lib/v2/tingshuitz/radar.js b/lib/v2/tingshuitz/radar.js index 3509309cd..2f0ff9c4c 100644 --- a/lib/v2/tingshuitz/radar.js +++ b/lib/v2/tingshuitz/radar.js @@ -42,6 +42,17 @@ module.exports = { }, ], }, + 'sz-water.com.cn': { + _name: '停水通知', + '.': [ + { + title: '深圳市', + docs: 'https://docs.rsshub.app/forecast.html#ting-shui-tong-zhi', + source: ['/*'], + target: '/tingshuitz/shenzhen', + }, + ], + }, 'whwater.com': { _name: '停水通知', '.': [ diff --git a/lib/v2/tingshuitz/router.js b/lib/v2/tingshuitz/router.js index d37c37d64..280a90b0a 100644 --- a/lib/v2/tingshuitz/router.js +++ b/lib/v2/tingshuitz/router.js @@ -5,6 +5,7 @@ module.exports = (router) => { router.get('/guangzhou', require('./guangzhou')); router.get('/hangzhou', require('./hangzhou')); router.get('/nanjing', require('./nanjing')); + router.get('/shenzhen', require('./shenzhen')); router.get('/wuhan/:channelId?', require('./wuhan')); router.get('/xian', require('./xian')); router.get('/xiaoshan', require('./xiaoshan')); diff --git a/lib/v2/tingshuitz/shenzhen.js b/lib/v2/tingshuitz/shenzhen.js new file mode 100644 index 000000000..e2eb3c72d --- /dev/null +++ b/lib/v2/tingshuitz/shenzhen.js @@ -0,0 +1,29 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); +const { art } = require('@/utils/render'); +const path = require('path'); + +module.exports = async (ctx) => { + const url = 'https://szgk.sz-water.com.cn/api/wechat/op/getStopWaterNotice'; + const response = await got({ + method: 'get', + url, + }); + + const data = response.data.data; + + ctx.state.data = { + title: '停水通知 - 深圳水务', + link: 'https://www.sz-water.com.cn/', + item: data.map((item) => ({ + title: `${item.position}${item.stoptime}`, + description: art(path.join(__dirname, 'templates/shenzhen.art'), { + item + }), + pubDate: timezone(parseDate(item.createdOn, 'YYYY-MM-DD HH:mm:ss'), +8), + link: 'https://szgk.sz-water.com.cn/wechat_web/Water_stop.html', + guid: `${item.position}${item.stopStartTime}`, + })), + }; +}; diff --git a/lib/v2/tingshuitz/templates/shenzhen.art b/lib/v2/tingshuitz/templates/shenzhen.art new file mode 100644 index 000000000..7fabd864f --- /dev/null +++ b/lib/v2/tingshuitz/templates/shenzhen.art @@ -0,0 +1,8 @@ +

{{ item.title }}

+

{{if item.reginName }} + 【{{ item.reginName }}】 +{{ /if }} +(影响用户{{ item.affectUser }}), +{{if item.stopwaterType }} + [{{ item.stopwaterType }}] +{{ /if }}原因:{{ item.reason }},停水开始时间{{ item.stopStartTime }},停水结束时间{{ item.stopEndTime }}

\ No newline at end of file