From 487b879043838a01a955f872d6adfa64766ebb59 Mon Sep 17 00:00:00 2001 From: Asa Venton Date: Sat, 31 Oct 2020 04:30:55 +0000 Subject: Add very basic support for departures and arrivals from a given airport. Not currently compatible with IRC bot. Update help. --- flightquery.sh | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'flightquery.sh') diff --git a/flightquery.sh b/flightquery.sh index 16910e6..cb8edb3 100755 --- a/flightquery.sh +++ b/flightquery.sh @@ -33,10 +33,30 @@ _getdata() { _arrivals() { _getdata + # TODO: Sort by something (arrival time?), limit to a certin number of flights (X before current time and Y after?) and format on single line of output + for json in $(echo "${result}" | jq -r '.data[] | @base64') + do + origin=$(_jq '.departure.airport') + takeoffSched=$(_jq '.departure.scheduled') + landingSched=$(_jq '.arrival.scheduled') + airline=$(_jq '.airline.name') + flightNumber=$(_jq '.flight.number') + echo "$airline $flightNumber Origin: $origin Takeoff: $takeoffSched Landed: $landingSched" + done } _departures() { _getdata + # TODO: Sort by something (departure time?), limit to a certin number of flights (X before current time and Y after?) and format on single line of output + for json in $(echo "${result}" | jq -r '.data[] | @base64') + do + destination=$(_jq '.arrival.airport') + takeoffSched=$(_jq '.departure.scheduled') + landingSched=$(_jq '.arrival.scheduled') + airline=$(_jq '.airline.name') + flightNumber=$(_jq '.flight.number') + echo "$airline $flightNumber destination: $destination Takeoff: $takeoffSched Landed: $landingSched" + done } _flight() { @@ -85,7 +105,7 @@ _flight() { } _help() { - echo "Usage: !flight [option] [flight]. Options: -h help, -d departures, -a arrivals, -s source." + echo "Usage: !flight [option] [flight/airport]. Options: -h help, -d departures [airport], -a arrivals [airport], -s source. If no option is set then you must provide an IATA flight number e.g. BA2775." } if [[ ${input} == "-h" ]] || [[ ${input} == "--help" ]] || [[ -z $input ]] -- cgit v1.2.3