1
0
Fork 0
mirror of https://github.com/kou029w/daraz-san.git synced 2025-01-18 16:08:06 +00:00
daraz-san/scripts/weather.js
2020-04-09 00:24:48 +09:00

39 lines
1,022 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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