From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 12188 invoked from network); 3 Apr 2021 21:04:55 -0000 Received: from 1ess.inri.net (216.126.196.35) by inbox.vuxu.org with ESMTPUTF8; 3 Apr 2021 21:04:55 -0000 Received: from mail-40132.protonmail.ch ([185.70.40.132]) by 1ess; Sat Apr 3 16:33:50 -0400 2021 Date: Sat, 03 Apr 2021 20:33:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1617482018; bh=gfaKrJKfs7tJI/heQWiriPT7I+txQ7v4sf3k/hbLR3g=; h=Date:To:From:Reply-To:Subject:From; b=kIDsGGogn88OuyW5QZJ3f3ZCck0+EaAf473+7Rw2Y/BDCcAjK9VEN0CrKAG6txB4H G8wSz0DwFjJ7a2/MYsb6lbyzENv6BUOdmZpnEevEx0lvqVf6ejBv3pBmRjCsHJiMa6 6kcCcmMrbOe/wSVmw4WHyYItPNYvm9Rvvs6vWVHY= To: "9front@9front.org" <9front@9front.org> From: kemal Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: ACPI CMS shader markup rails Subject: [9front] weather: rewrite with a new api Reply-To: 9front@9front.org Precedence: bulk hello, i have written a new "weather" script using a different api. old version was using telnet and stopped receiving updates, this one uses http with hget instead and has recent weather. diff -r cc26fdf57bb2 rc/bin/weather --- a/rc/bin/weather=09Sat Mar 13 14:57:53 2021 +0100 +++ b/rc/bin/weather=09Sat Apr 03 23:31:49 2021 +0300 @@ -1,46 +1,9 @@ #!/bin/rc - -rfork e - -DEFAULT=3Dewr - -fn usage{ -=09echo 'usage: weather 3-letter-city-code' >[1=3D2] -=09echo 'for a list of cities in new york, say' >[1=3D2] -=09echo '=09weather ny' >[1=3D2] -=09exit usage -} - -switch($#*){ -case 0 -=09arg=3D$DEFAULT -=09if(~ $#weather 1) -=09=09arg=3D$weather -case 1 -=09arg=3D$1 -case * -=09usage -} - -switch($arg){ -case [a-zA-Z][a-zA-Z][a-zA-Z] -=09script=3D('' '' 'C' '4' '1' '1' $arg '' '' '' '' 'X') -case [a-zA-Z][a-zA-Z] -=09script=3D('' '' 'C' '4' '1' '3' $arg '' '' '' '' 'X') -case * -=09usage -} - -{ -=09for(i in $script) -=09=09echo $i -} | -con -nrl tcp!rainmaker.wunderground.com!telnet | -sed -n '/Enter .-letter .* code:/,/CITY FORECAST MENU/p' | -sed 's/Enter .-letter .* code: //' | -sed 's/ Press Return to continue, M to return to menu, X to exit: //' | -grep -v 'CITY FORECAST MENU' | -tr -d ' ' | -sed 's/ *$//' | -uniq | -sed -n '/^VTEC/q; p' +loc=3D'' +if (! ~ $#* 0) +=09loc=3D`{echo $* | sed 's/ +/+/g'} +if not +=09if (! ~ $#weather 0) +=09=09loc=3D$weather +hget https://wttr.in/$loc?TA0 +echo diff -r cc26fdf57bb2 sys/man/1/weather --- a/sys/man/1/weather=09Sat Mar 13 14:57:53 2021 +0100 +++ b/sys/man/1/weather=09Sat Apr 03 23:31:49 2021 +0300 @@ -4,37 +4,24 @@ .SH SYNOPSIS .B weather [ -.I air -] [ -.I st +.I location ] .SH DESCRIPTION .I Weather -prints the local conditions and seven-day forecast most recently reported = at the -.SM US -airport with the three-letter location identifier -.IR air . -Given a two-letter -.SM US -state abbreviation -.I st -instead, -.I weather -prints a table of -.I air -location identifiers known for -.IR st . -.PP -The arguments are mutually exclusive and case-insensitive. -If neither is given, -.I air -defaults to the value of the environment variable -.BR $weather , -or if it is unset, -to the location identifier -.BR ewr , -designating the Newark, NJ, airport near Bell Labs, Murray Hill. +by using wttr.in prints the local conditions most recently reported at the= given +.IR location , +the enviroment variable +.B $weather +or at detected location if neither are given. +Any location (area codes, airport codes, any location names) usually works= . +Some special places might require putting a tilde +.RB ( ~ ) +at the beginning. Weather of IP adresses or domain names can be found by t= yping an at sign +.RB ( @ ) +the beginning. Location format can change, see https://wttr.in/:help for m= ore info. .SH SOURCE .B /rc/bin/weather .SH BUGS Weather is hopelessly provincial. + +Redesigns of the wttr.in API might break this program.