diff --git a/workflows/u/akiracraftwork/hourly_chime__flow/flow.yaml b/workflows/u/akiracraftwork/hourly_chime__flow/flow.yaml index d896467..d9768c5 100644 --- a/workflows/u/akiracraftwork/hourly_chime__flow/flow.yaml +++ b/workflows/u/akiracraftwork/hourly_chime__flow/flow.yaml @@ -1,5 +1,5 @@ summary: 鳩時計機能 -description: '' +description: 毎正時にAlexaで時刻を読み上げる。失敗時はLINEで通知。 value: modules: - id: a @@ -18,6 +18,69 @@ value: value: です lock: '!inline a.lock' language: bun + failure_module: + id: failure + summary: エラー時LINE通知 + value: + type: rawscript + content: | + import * as wmill from "windmill-client"; + + export async function main() { + const token = await wmill.getVariable("u/admin/LINE_CHANNEL_ACCESS_TOKEN"); + const to = await wmill.getVariable("u/admin/LINE_TO"); + + const message = [ + "\u26a0\ufe0f \u9ce9\u6642\u8a08\u30a8\u30e9\u30fc", + "", + "Alexa TTS API \u304c\u5931\u6557\u3057\u307e\u3057\u305f\u3002", + "Cookie\u306e\u671f\u9650\u5207\u308c\u306e\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002", + "", + "\u5bfe\u51e6: auth4.js \u3067 Cookie \u3092\u518d\u53d6\u5f97\u3057\u3066\u304f\u3060\u3055\u3044\u3002" + ].join("\n"); + + const res = await fetch("https://api.line.me/v2/bot/message/push", { + method: "POST", + headers: { + "Authorization": `Bearer ${token}`, + "Content-Type": "application/json", + }, + body: JSON.stringify({ + to: to, + messages: [{ type: "text", text: message }], + }), + }); + + if (!res.ok) { + const body = await res.text(); + throw new Error(`LINE API error ${res.status}: ${body}`); + } + + return { notified: true }; + } + input_transforms: {} + lock: | + { + "dependencies": { + "windmill-client": "latest" + } + } + //bun.lock + { + "lockfileVersion": 1, + "configVersion": 1, + "workspaces": { + "": { + "dependencies": { + "windmill-client": "latest", + }, + }, + }, + "packages": { + "windmill-client": ["windmill-client@1.661.0", "", {}, "sha512-vEosrP1NKVHJMi6gEnKnvd3QrNeoy0W0PYqAIIKvg0B4K4ejpw9zbvrytVvoSb7XC3Fb9PzYdvGFqdfaVCCTvg=="], + } + } + language: bun schema: $schema: 'https://json-schema.org/draft/2020-12/schema' type: object