mirror of
https://github.com/kou029w/daraz-san.git
synced 2025-01-18 16:08:06 +00:00
21 lines
662 B
JavaScript
21 lines
662 B
JavaScript
const get_video_id = require("get-video-id");
|
|
|
|
const API_KEY = "Q8mtkFkP4Zru4mlDd812iw2vcQwx5B0qIsUKsxit";
|
|
|
|
module.exports = [
|
|
/apod|galaxy|spa+ce|宇宙|コスモ|銀河/i,
|
|
async ({ say }) => {
|
|
const response = await fetch(
|
|
`https://api.nasa.gov/planetary/apod?api_key=${API_KEY}`
|
|
);
|
|
if (!response.ok) {
|
|
return say("APODの画像が取れなかったにゃーん");
|
|
}
|
|
const dict = await response.json();
|
|
const url =
|
|
dict.media_type === "video"
|
|
? `https://www.youtube.com/watch?v=${get_video_id(dict.url)}`
|
|
: dict.url;
|
|
return say(`宇宙って良いにゃーん\n${dict.title}\n${url}`);
|
|
},
|
|
];
|