天気チェック
コミュニティOpenMeteo API(キー不要)で任意の都市の現在の天気を取得します。
インストール
Save as `weather.js`. Usage: `weather <lat> <lon>`.
ソースコード
JavaScriptTutorial.terminal
// weather.js
// Description: Get weather for a location (lat, lon)
module.exports = async function(context) {
// Default to San Francisco if no args
const lat = context.args[0] || 37.7749;
const lon = context.args[1] || -122.4194;
const url = `https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${lon}¤t_weather=true`;
const response = await fetch(url);
const data = await response.json();
return {
location: { lat, lon },
weather: data.current_weather
};
};
プレビュー
● ライブデモAgent セッション
使い方
- 必要な依存関係があれば、事前にインストールします。
- ファイルを OpenClaw のスキルフォルダ(例:~/.openclaw/skills/)に配置します。
- エージェントを再起動するか、設定をリロードします。
- ファイル名(拡張子なし)をツール名として呼び出すか、説明が十分なら自然言語で呼び出します。