Auto-sync: 2026-03-03 05:00:01
This commit is contained in:
29
workflows/u/akiracraftwork/hourly_chime__flow/a.ts
Normal file
29
workflows/u/akiracraftwork/hourly_chime__flow/a.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
export async function main(
|
||||
device: string = "オフィスの右エコー",
|
||||
prefix: string = "現在時刻は",
|
||||
suffix: string = "です"
|
||||
) {
|
||||
const now = new Date();
|
||||
const hhmm = new Intl.DateTimeFormat("ja-JP", {
|
||||
timeZone: "Asia/Tokyo",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
hour12: false,
|
||||
}).format(now); // 例: 09:30
|
||||
|
||||
const [h, m] = hhmm.split(":");
|
||||
const text = `${prefix}${Number(h)}時${Number(m)}分${suffix}`;
|
||||
|
||||
const res = await fetch("http://alexa_api:3500/speak", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ device, text }),
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const body = await res.text();
|
||||
throw new Error(`alexa-api error ${res.status}: ${body}`);
|
||||
}
|
||||
|
||||
return { ok: true, device, text };
|
||||
}
|
||||
Reference in New Issue
Block a user