Introduction
Introduction Statistics Contact Development Disclaimer Help
Add METAR to annna. - annna - Annna the nice friendly bot.
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6…
Log
Files
Refs
Tags
README
---
commit 58d3d554ce0e9955b0444a80ed162ecf5a6e2c4d
parent a6b2003f535663399675790e9e4e233e77a31892
Author: eidolon <?>
Date: Wed, 9 Oct 2024 11:08:49 -0400
Add METAR to annna.
Signed-off-by: Annna Robert-Houdin <[email protected]>
Diffstat:
M annna-message-common | 4 ++++
A metar | 17 +++++++++++++++++
2 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/annna-message-common b/annna-message-common
@@ -721,6 +721,10 @@ case "${text}" in
fi
} &
;;
+"${ircuser}, METAR for "*|"${ircuser}, metar for "*)
+ resp=$(metar "$(printf '%.4s\n' "${text##* }")")
+ annna-say -s "${server}" -c "${channel}" "${user}, ${resp}"
+ ;;
"${ircuser}, how discriminating is "*)
word="$(printf "%s\n" "${text}" | cut -c 30- | sed 's,\t, ,g')"
case "$word" in
diff --git a/metar b/metar
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+if ! id=$(printf '%s\n' "$1" | grep '^[A-Za-z]\{4\}$'); then
+ printf '%s\n' "invalid ICAO 7910 airport code."
+ exit 1
+fi
+
+fmt=raw
+uri="https://aviationweather.gov/api/data/metar/"
+metar=$(curl -Ssfm 5 --data-urlencode format="$fmt" --data-urlencode ids="$id"…
+
+if [ -z "$metar" ]; then
+ printf '%s\n' "error retrieving METAR for $id."
+ exit 1
+fi
+
+printf '%s\n' "$metar"
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.