add auto trig for api and send via telegram

This commit is contained in:
Your Name
2026-08-05 11:49:27 -04:00
parent bd92c7f899
commit d722842d20
19 changed files with 739 additions and 61 deletions
+43
View File
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
set -euo pipefail
# Entertainment plugin: gold spot price (XAU/USD) via goldprice.dev (no API key).
# POS_PLUGIN: gold
# Contract: stdout is the message sent by 'pos entertainment send gold'.
err() { echo "ERROR: $*" >&2; exit 1; }
case "${1:-}" in
-h|--help)
cat <<EOF
Usage: pos entertainment send gold
Gold spot price (XAU/USD) from goldprice.dev (no API key, free anonymous tier).
Example:
pos entertainment send gold --print
EOF
exit 0
;;
esac
command -v curl &>/dev/null || err "curl not found"
command -v jq &>/dev/null || err "jq not found"
if ! json="$(curl -fsS --max-time 20 \
"https://api.goldprice.dev/v1/prices?symbol=XAU-USD-SPOT")"; then
err "Failed to fetch gold price from goldprice.dev"
fi
symbol="$(jq -r '.symbols[0].symbol' <<<"$json")"
price="$(jq -r '.symbols[0].price' <<<"$json")"
bid="$(jq -r '.symbols[0].bid' <<<"$json")"
ask="$(jq -r '.symbols[0].ask' <<<"$json")"
unit="$(jq -r '.symbols[0].unit' <<<"$json")"
when="$(jq -r '.symbols[0].computed_at' <<<"$json")"
when="${when/T/ }"; when="${when%Z}"
[ -n "$price" ] || err "No price received"
printf 'Gold spot (%s/USD): %s USD/%s\nBid %s · Ask %s\nas of %s UTC\n' \
"$symbol" "$price" "$unit" "$bid" "$ask" "$when"
+1
View File
@@ -2,6 +2,7 @@
set -euo pipefail
# Entertainment plugin: random dad joke via icanhazdadjoke.com (no API key).
# POS_PLUGIN: joke
# Contract: stdout is the message sent by 'pos entertainment send joke'.
err() { echo "ERROR: $*" >&2; exit 1; }
+1
View File
@@ -2,6 +2,7 @@
set -euo pipefail
# Entertainment plugin: current weather via Open-Meteo (no API key).
# POS_PLUGIN: weather
# Contract: stdout is the message sent by 'pos entertainment send weather'.
err() { echo "ERROR: $*" >&2; exit 1; }