From 6c17683cc26684d7ab5c6f36c22eb57a915cc930 Mon Sep 17 00:00:00 2001 From: Last2014 Date: Mon, 30 Jun 2025 10:52:02 +0900 Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E5=90=8D=E3=81=9A=E3=81=A4=E8=BF=94?= =?UTF-8?q?=E4=BF=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/weatherNotice.ts | 54 ++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/scripts/weatherNotice.ts b/scripts/weatherNotice.ts index 182d98f..9dd765a 100644 --- a/scripts/weatherNotice.ts +++ b/scripts/weatherNotice.ts @@ -5,7 +5,7 @@ import type * as types from "../types"; dotenv.config(); export default async function weatherNotice() { - /*// 仮投稿 + // 仮投稿 const resUeuse = await fetch( `https://${process.env.SERVER}/api/ueuse/create`, { @@ -22,12 +22,9 @@ export default async function weatherNotice() { const ueuseData: types.ueuseCreateApi = await resUeuse.json(); - console.log(JSON.stringify(ueuseData));*/ + console.log(JSON.stringify(ueuseData)); - - let weatherResults: string = ""; - - for (let i = 0; i < cityList.length; i++) { + for (let i = 0; i < cityList.length; i++) {setTimeout(async () => { const res = await fetch( `https://weather.tsukumijima.net/api/forecast/city/${cityList[i]}`, ); @@ -40,31 +37,28 @@ export default async function weatherNotice() { const minTemp = today.temperature.min?.celsius ?? "取得できませんでした"; const chanceOfRain = data.chanceOfRain?.["T06_12"] ?? "取得できませんでした"; - weatherResults = weatherResults + - `【${data.location.city} 】\n - 天気:${weather}\n - 最高気温:${maxTemp}℃\n - 最低気温:${minTemp}℃\n - 降水確率:${chanceOfRain} - `; - } - console.log(weatherResults); + // 天気を返信 + const resReply = await fetch( + `https://${process.env.SERVER}/api/ueuse/create`, + { + method: "POST", + body: JSON.stringify({ + token: process.env.TOKEN, + text: ` + 【${data.location.city} 】\n + 天気:${weather}\n + 最高気温:${maxTemp}℃\n + 最低気温:${minTemp}℃\n + 降水確率:${chanceOfRain} + `, + replyid: ueuseData.uniqid + }), + }, + ); - /*// 天気を返信 - const resReply = await fetch( - `https://${process.env.SERVER}/api/ueuse/create`, - { - method: "POST", - body: JSON.stringify({ - token: process.env.TOKEN, - text: weatherResults, - replyid: ueuseData.uniqid - }), - }, - ); + const replyData: types.ueuseCreateApi = await resReply.json(); - const replyData: types.ueuseCreateApi = await resReply.json(); - - console.log(JSON.stringify(replyData));*/ + console.log(JSON.stringify(replyData)); + }, 500)} }