2019-07-28 01:52:06 +09:00
|
|
|
|
const subMinutes = require("date-fns/subMinutes");
|
|
|
|
|
const roundToNearestMinutes = require("date-fns/roundToNearestMinutes");
|
2019-09-02 01:31:06 +09:00
|
|
|
|
const format = require("date-fns-tz/format");
|
|
|
|
|
const utcToZonedTime = require("date-fns-tz/utcToZonedTime");
|
2019-07-28 01:52:06 +09:00
|
|
|
|
const nyanco = require("./util/nyanco");
|
|
|
|
|
|
2019-09-02 01:31:06 +09:00
|
|
|
|
const timeZone = "Asia/Tokyo";
|
2019-07-28 01:52:06 +09:00
|
|
|
|
const prefNumber = 34;
|
|
|
|
|
const pageURL = `https://www.tenki.jp/radar/7/${prefNumber}/`;
|
2020-04-09 00:16:46 +09:00
|
|
|
|
const imgURL = (target) =>
|
2019-07-28 01:52:06 +09:00
|
|
|
|
[
|
|
|
|
|
"https://static.tenki.jp/static-images/radar/",
|
2019-09-02 01:31:06 +09:00
|
|
|
|
format(target, "yyyy/MM/dd/HH/mm/ss", { timeZone }),
|
2020-04-09 00:16:46 +09:00
|
|
|
|
`/pref-${prefNumber}-large.jpg`,
|
2019-07-28 01:52:06 +09:00
|
|
|
|
].join("");
|
|
|
|
|
|
|
|
|
|
module.exports = [
|
|
|
|
|
/天気/,
|
|
|
|
|
async ({ say }) => {
|
2019-09-02 01:31:06 +09:00
|
|
|
|
const target = utcToZonedTime(
|
|
|
|
|
roundToNearestMinutes(subMinutes(new Date(), 5), {
|
2020-04-09 00:16:46 +09:00
|
|
|
|
nearestTo: 5,
|
2019-09-02 01:31:06 +09:00
|
|
|
|
}),
|
|
|
|
|
timeZone
|
|
|
|
|
);
|
2019-07-28 01:52:06 +09:00
|
|
|
|
|
2020-04-09 00:24:48 +09:00
|
|
|
|
return say(
|
2019-07-28 01:52:06 +09:00
|
|
|
|
[
|
2019-09-02 01:31:06 +09:00
|
|
|
|
`${nyanco()} < ${format(
|
|
|
|
|
target,
|
|
|
|
|
"HH時mm分の雨雲の様子にゃーん",
|
|
|
|
|
timeZone
|
|
|
|
|
)}`,
|
2019-07-28 01:52:06 +09:00
|
|
|
|
imgURL(target),
|
2020-04-09 00:16:46 +09:00
|
|
|
|
pageURL,
|
2019-07-28 01:52:06 +09:00
|
|
|
|
].join("\n")
|
|
|
|
|
);
|
2020-04-09 00:16:46 +09:00
|
|
|
|
},
|
2019-07-28 01:52:06 +09:00
|
|
|
|
];
|