重构仓库目录为统一的 runtime 分层并清理历史 openclaw 残留。

本次迁移将网关/通道/工具/技能/脚本与协议资源集中到新结构,统一路径常量与脚本转发机制,减少顶层噪音并保证运行与测试行为一致。

Made-with: Cursor
This commit is contained in:
oliver 2026-04-25 01:24:23 +08:00
parent ba3836f00f
commit 4a23b715a2
498 changed files with 2760 additions and 2200 deletions

View file

@ -0,0 +1,63 @@
---
name: weather
description: Get current weather and forecasts (no API key required).
homepage: https://wttr.in/:help
metadata:
clawdbot:
emoji: "🌤️"
requires:
bins: ["curl"]
oclaw:
runtime:
type: python
entry: scripts/run.py
schema:
type: object
properties:
location: { type: string, description: "City name (e.g. Shanghai, London)" }
format: { type: string, description: "wttr.in format (default: 3)" }
additionalProperties: false
---
# Weather
Two free services, no API keys needed.
## wttr.in (primary)
Quick one-liner:
```bash
curl -s "wttr.in/London?format=3"
# Output: London: ⛅️ +8°C
```
Compact format:
```bash
curl -s "wttr.in/London?format=%l:+%c+%t+%h+%w"
# Output: London: ⛅️ +8°C 71% ↙5km/h
```
Full forecast:
```bash
curl -s "wttr.in/London?T"
```
Format codes: `%c` condition · `%t` temp · `%h` humidity · `%w` wind · `%l` location · `%m` moon
Tips:
- URL-encode spaces: `wttr.in/New+York`
- Airport codes: `wttr.in/JFK`
- Units: `?m` (metric) `?u` (USCS)
- Today only: `?1` · Current only: `?0`
- PNG: `curl -s "wttr.in/Berlin.png" -o /tmp/weather.png`
## Open-Meteo (fallback, JSON)
Free, no key, good for programmatic use:
```bash
curl -s "https://api.open-meteo.com/v1/forecast?latitude=51.5&longitude=-0.12&current_weather=true"
```
Find coordinates for a city, then query. Returns JSON with temp, windspeed, weathercode.
Docs: https://open-meteo.com/en/docs

View file

@ -0,0 +1,6 @@
{
"ownerId": "kn70pywhg0fyz996kpa8xj89s57yhv26",
"slug": "weather",
"version": "1.0.0",
"publishedAt": 1767545394459
}

View file

@ -0,0 +1,54 @@
from __future__ import annotations
import json
import sys
import urllib.parse
import urllib.request
def _read_stdin_json() -> dict:
try:
raw = input()
except EOFError:
raw = ""
raw = (raw or "").strip()
if not raw:
return {}
try:
obj = json.loads(raw)
except Exception:
return {}
return obj if isinstance(obj, dict) else {}
def main() -> None:
# Windows default console encoding may be GBK; force UTF-8 so symbols like ☀ do not crash.
try:
sys.stdout.reconfigure(encoding="utf-8")
except Exception:
pass
payload = _read_stdin_json()
args = payload.get("args") if isinstance(payload.get("args"), dict) else {}
location = str(args.get("location") or "Shanghai").strip() or "Shanghai"
fmt = str(args.get("format") or "3").strip() or "3"
# wttr.in: GET /<location>?format=<fmt>
loc_q = urllib.parse.quote(location, safe="")
url = f"https://wttr.in/{loc_q}?format={urllib.parse.quote(fmt, safe='')}"
req = urllib.request.Request(url, headers={"User-Agent": "oclaw-skill-weather/1.0"})
try:
with urllib.request.urlopen(req, timeout=10) as resp:
text = resp.read().decode("utf-8", errors="ignore").strip()
out = {"ok": True, "location": location, "format": fmt, "text": text}
except Exception as exc:
out = {"ok": False, "error_code": "fetch_failed", "error": f"{type(exc).__name__}:{exc}"}
output = json.dumps(out, ensure_ascii=False)
try:
print(output)
except UnicodeEncodeError:
# Last-resort fallback for environments where stdout reconfigure is unavailable.
sys.stdout.buffer.write((output + "\n").encode("utf-8", errors="replace"))
if __name__ == "__main__":
main()