Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Example is not the main thing in influencing others. It is the only thing. -- Albert Schweitzer


dovenet / Synchronet Javascript / Weather alerts to IRC room

SubjectAuthor
* Weather alerts to IRC roomansunent
+* Weather alerts to IRC roomDigital Man
|`* Weather alerts to IRC roomansunent
| `* Weather alerts to IRC roomDigital Man
|  `* Weather alerts to IRC roomansunent
|   `- Weather alerts to IRC roomechicken
`* Re: Weather alerts to IRC roomNelgin
 `- Re: Weather alerts to IRC roomMRO

1
Weather alerts to IRC room

<63CE2C06.182.dove-syncjs@ansun-enterprises.com>

 copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=849&group=DOVE-Net.Synchronet_Javascript#849

 copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: ansunent@VERT/ANSUN (ansunent)
To: all
Subject: Weather alerts to IRC room
Message-ID: <63CE2C06.182.dove-syncjs@ansun-enterprises.com>
Date: Sun, 22 Jan 2023 17:41:10 -0600
X-Comment-To: all
Path: rocksolidbbs.com!not-for-mail
Organization: ANSUN Exchange
Newsgroups: DOVE-Net.Synchronet_Javascript
X-FTN-PID: Synchronet 3.18b-Win32 Sep 20 2020 MSC 1927
X-FTN-CHRS: UTF-8 4
WhenImported: 20230122233557-0800 41e0
WhenExported: 20230123041825-0800 41e0
ExportedFrom: VERT sync-js 3786
WhenImported: 20230123004110-0600 4168
WhenExported: 20230123013554-0600 4168
ExportedFrom: ANSUN dove-syncjs 182
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
 by: ansunent - Sun, 22 Jan 2023 23:41 UTC

Hey can anyone check out this script and tell me where it may have gone wrong?
I keep getting a syntax error on line 17

Line 17: https.get(weatherURL, (res) => {

The purpose of the script is to periodically check weather.gov for new or
updated severe weather alerts and to post those in my IRC room. Below is the
whole script. I appreciate any help you can give.

const https = require("http.js");
const irc = require("irc.js");

const weatherURL = "https://api.weather.gov/alerts/active/zone/";

const client = new irc.Client("mybbs.synchro.net", "WeatherAlert", {
channels: ["#weather"],
});

client.addListener("message", function (from, to, message) {
if (message === "!weather") {
getWeatherAlerts(to);
}
});

function getWeatherAlerts(channel) {
https.get(weatherURL, (res) => {
let data = "";
res.on("data", (chunk) => {
data += chunk;
});
res.on("end", () => {
const alerts = JSON.parse(data).features;
if (alerts.length === 0) {
client.say(channel, "No severe weather alerts at this time.");
return;
}
alerts.forEach((alert) => {
client.say(channel, alert.properties.headline);
});
});
});
}

---
� Synchronet � ANSUN - ansun.synchro.net

Weather alerts to IRC room

<63CEC249.3787.sync-js@vert.synchro.net>

 copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=850&group=DOVE-Net.Synchronet_Javascript#850

 copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: digital.man@VERT (Digital Man)
To: ansunent
Subject: Weather alerts to IRC room
Message-ID: <63CEC249.3787.sync-js@vert.synchro.net>
Date: Mon, 23 Jan 2023 02:22:17 -0800
X-Comment-To: ansunent
Path: rocksolidbbs.com!not-for-mail
Organization: Vertrauen
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <63CE2C06.182.dove-syncjs@ansun-enterprises.com>
References: <63CE2C06.182.dove-syncjs@ansun-enterprises.com>
X-FTN-PID: Synchronet 3.20a-Linux master/f3ec8613a Jan 21 2023 GCC 12.2.0
X-FTN-CHRS: CP437 2
WhenImported: 20230123092217-0800 41e0
WhenExported: 20230123101819-0800 41e0
ExportedFrom: VERT sync-js 3787
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: Digital Man - Mon, 23 Jan 2023 10:22 UTC

Re: Weather alerts to IRC room
By: ansunent to all on Mon Jan 23 2023 12:41 am

> Hey can anyone check out this script and tell me where it may have gone
> wrong? I keep getting a syntax error on line 17
>
> Line 17: https.get(weatherURL, (res) => {

The JavaScript engine used by Synchronet (i.e. libmozjs, aka SpiderMonkey, v1.8.5) implements EMCAScript 5 (ES5) and thus does not support JS bullet operators.
https://en.wikipedia.org/wiki/ECMAScript_version_history#5th_Edition_%E2%80%93_ECMAScript_2009
--
digital man (rob)

Synchronet "Real Fact" #48:
Synchronet directory naming (i.e. ctrl, exec, data) was suggested by S. Deppe
Norco, CA WX: 50.9°F, 29.0% humidity, 3 mph NE wind, 0.00 inches rain/24hrs
---
■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net

Weather alerts to IRC room

<63CF2CB2.184.dove-syncjs@ansun-enterprises.com>

 copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=851&group=DOVE-Net.Synchronet_Javascript#851

 copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: ansunent@VERT/ANSUN (ansunent)
To: Digital Man
Subject: Weather alerts to IRC room
Message-ID: <63CF2CB2.184.dove-syncjs@ansun-enterprises.com>
Date: Mon, 23 Jan 2023 11:56:18 -0600
X-Comment-To: Digital Man
Path: rocksolidbbs.com!not-for-mail
Organization: ANSUN Exchange
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <63CEC249.3787.sync-js@vert.synchro.net>
References: <63CEC249.3787.sync-js@vert.synchro.net>
X-FTN-PID: Synchronet 3.18b-Win32 Sep 20 2020 MSC 1927
X-FTN-CHRS: UTF-8 4
WhenImported: 20230123193605-0800 41e0
WhenExported: 20230123221821-0800 41e0
ExportedFrom: VERT sync-js 3788
WhenImported: 20230123185618-0600 4168
WhenExported: 20230123193557-0600 4168
ExportedFrom: ANSUN dove-syncjs 184
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
 by: ansunent - Mon, 23 Jan 2023 17:56 UTC

> Re: Weather alerts to IRC room
> By: ansunent to all on Mon Jan 23 2023 12:41 am

> The JavaScript engine used by Synchronet (i.e. libmozjs, aka SpiderMonkey,
> v1.8.5) implements EMCAScript 5 (ES5) and thus does not support JS bullet
> operators.
> https://en.wikipedia.org/wiki/ECMAScript_version_history#5th_Edition_%E2%80%9
> 3_ECMAScript_2009
> --
> digital man (rob)

> Synchronet "Real Fact" #48:
> Synchronet directory naming (i.e. ctrl, exec, data) was suggested by S. Deppe
> Norco, CA WX: 50.9�F, 29.0% humidity, 3 mph NE wind, 0.00 inches rain/24hrs

> ---
> � Synchronet � Vertrauen � Home of Synchronet �
> [vert/cvs/bbs].synchro.net

Still learning so please bear with me. I really appreciate the information.

It sounds like we're specifically saying that the "=>" is the problem or at
least one of the syntax problems Am I right?

---
� Synchronet � ANSUN - ansun.synchro.net

Weather alerts to IRC room

<63CF5F40.3789.sync-js@vert.synchro.net>

 copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=852&group=DOVE-Net.Synchronet_Javascript#852

 copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: digital.man@VERT (Digital Man)
To: ansunent
Subject: Weather alerts to IRC room
Message-ID: <63CF5F40.3789.sync-js@vert.synchro.net>
Date: Mon, 23 Jan 2023 13:32:00 -0800
X-Comment-To: ansunent
Path: rocksolidbbs.com!not-for-mail
Organization: Vertrauen
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <63CF2CB2.184.dove-syncjs@ansun-enterprises.com>
References: <63CF2CB2.184.dove-syncjs@ansun-enterprises.com>
X-FTN-PID: Synchronet 3.20a-Linux master/48cc8617d Jan 23 2023 GCC 12.2.0
X-FTN-CHRS: CP437 2
WhenImported: 20230123203200-0800 41e0
WhenExported: 20230123221821-0800 41e0
ExportedFrom: VERT sync-js 3789
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: Digital Man - Mon, 23 Jan 2023 21:32 UTC

Re: Weather alerts to IRC room
By: ansunent to Digital Man on Mon Jan 23 2023 06:56 pm

> > Re: Weather alerts to IRC room
> > By: ansunent to all on Mon Jan 23 2023 12:41 am
>
> > The JavaScript engine used by Synchronet (i.e. libmozjs, aka SpiderMonkey,
> > v1.8.5) implements EMCAScript 5 (ES5) and thus does not support JS bullet
> > operators. https://en.wikipedia.org/wiki/ECMAScript_version_history#5th_Ed
> > ition_%E2%80%9 3_ECMAScript_2009
> > --
> > digital man (rob)
>
> > Synchronet "Real Fact" #48:
> > Synchronet directory naming (i.e. ctrl, exec, data) was suggested by S.
> > Deppe Norco, CA WX: 50.9¿F, 29.0% humidity, 3 mph NE wind, 0.00 inches
> > rain/24hrs
>
> > ---
> > ¿ Synchronet ¿ Vertrauen ¿ Home of Synchronet ¿
> > [vert/cvs/bbs].synchro.net
>
>
>
> Still learning so please bear with me. I really appreciate the information.
>
> It sounds like we're specifically saying that the "=>" is the problem or at
> least one of the syntax problems Am I right?

Right. => is often called a rocket operator (or "Arrow function expression") and is not supported in earlier JS implementations. Sorry, not "bullet operator" like I said.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
--
digital man (rob)

This Is Spinal Tap quote #42:
What day the Lord created Spinal Tap and couldn't he have rested on that day?
Norco, CA WX: 54.9°F, 29.0% humidity, 4 mph SSE wind, 0.00 inches rain/24hrs
---
■ Synchronet ■ Vertrauen ■ Home of Synchronet ■ [vert/cvs/bbs].synchro.net

Weather alerts to IRC room

<63CF7B42.186.dove-syncjs@ansun-enterprises.com>

 copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=853&group=DOVE-Net.Synchronet_Javascript#853

 copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: ansunent@VERT/ANSUN (ansunent)
To: Digital Man
Subject: Weather alerts to IRC room
Message-ID: <63CF7B42.186.dove-syncjs@ansun-enterprises.com>
Date: Mon, 23 Jan 2023 17:31:30 -0600
X-Comment-To: Digital Man
Path: rocksolidbbs.com!not-for-mail
Organization: ANSUN Exchange
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <63CF5F40.3789.sync-js@vert.synchro.net>
References: <63CF5F40.3789.sync-js@vert.synchro.net>
X-FTN-PID: Synchronet 3.18b-Win32 Sep 20 2020 MSC 1927
X-FTN-CHRS: UTF-8 4
WhenImported: 20230123223605-0800 41e0
WhenExported: 20230124041815-0800 41e0
ExportedFrom: VERT sync-js 3790
WhenImported: 20230124003130-0600 4168
WhenExported: 20230124003559-0600 4168
ExportedFrom: ANSUN dove-syncjs 186
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
 by: ansunent - Mon, 23 Jan 2023 23:31 UTC

> Re: Weather alerts to IRC room
> By: ansunent to Digital Man on Mon Jan 23 2023 06:56 pm

> Right. => is often called a rocket operator (or "Arrow function expression")
> and is not supported in earlier JS implementations. Sorry, not "bullet
> operator" like I said.
> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/A
> rrow_functions
> --
> digital man (rob)

> This Is Spinal Tap quote #42:
> What day the Lord created Spinal Tap and couldn't he have rested on that day?
> Norco, CA WX: 54.9�F, 29.0% humidity, 4 mph SSE wind, 0.00 inches
> rain/24hrs

> ---
> � Synchronet � Vertrauen � Home of Synchronet �
> [vert/cvs/bbs].synchro.net

That makes sense. I'll look into what I need to use in substitution for this
"=>".

Much appreciated, DM.

---
� Synchronet � ANSUN - ansun.synchro.net

Weather alerts to IRC room

<63D2DB50.3759.sync_js@bbs.electronicchicken.com>

 copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=854&group=DOVE-Net.Synchronet_Javascript#854

 copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: echicken@VERT/ECBBS (echicken)
To: ansunent
Subject: Weather alerts to IRC room
Message-ID: <63D2DB50.3759.sync_js@bbs.electronicchicken.com>
Date: Thu, 26 Jan 2023 12:58:08 -0500
X-Comment-To: ansunent
Path: rocksolidbbs.com!not-for-mail
Organization: electronic chicken bbs
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <63CF7B42.186.dove-syncjs@ansun-enterprises.com>
References: <63CF7B42.186.dove-syncjs@ansun-enterprises.com>
X-FTN-PID: Synchronet 3.20a-Linux master/5b77181de Jan 4 2023 GCC 9.4.0
X-FTN-CHRS: CP437 2
WhenImported: 20230126120615-0800 41e0
WhenExported: 20230126161820-0800 41e0
ExportedFrom: VERT sync-js 3792
WhenImported: 20230126195808-0500 412c
WhenExported: 20230126200618Z 412c
ExportedFrom: ECBBS sync_js 3759
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: echicken - Thu, 26 Jan 2023 17:58 UTC

Re: Weather alerts to IRC room
By: ansunent to Digital Man on Tue Jan 24 2023 00:31:30

an> That makes sense. I'll look into what I need to use in substitution for
an> this "=>".

You've got other problems beyond incompatible syntax.

In the code that you posted, you were doing something like:

http.get(url, res => {
let data = '';
res.on('data', d => data += d);
res.on('end', () => {
// do stuff with data
});
});

I suspect you took inspiration from a rather outdated node.js example. None of this will work here. In fact a vast amount of example JS code that you find online simply won't work here without significant alteration.

You want something like:

function getWeatherAlerts(channel) {
var data = http.Get(weatherURL);
var alerts = JSON.parse(data).features;
if (alerts.length < 1) {
client.say(channel, 'No severe weather alerts at this time.');
} else {
alerts.forEach(function (alert) {
client.say(channel, alert.properties.headline);
});
}
}
---
echicken
electronic chicken bbs - bbs.electronicchicken.com
---
■ Synchronet ■ electronic chicken bbs - bbs.electronicchicken.com

Re: Weather alerts to IRC room

<20230131014033.1fc8e9bc@wibble.sysadmininc.com>

 copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=858&group=DOVE-Net.Synchronet_Javascript#858

 copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: nelgin@VERT/EOTLBBS (Nelgin)
To: ansunent
Subject: Re: Weather alerts to IRC room
Message-ID: <20230131014033.1fc8e9bc@wibble.sysadmininc.com>
Date: Mon, 30 Jan 2023 18:40:33 -0600
X-Comment-To: ansunent
Path: rocksolidbbs.com!not-for-mail
Organization: End Of The Line BBS
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <63CE2C06.182.dove-syncjs@ansun-enterprises.com>
References: <63CE2C06.182.dove-syncjs@ansun-enterprises.com>
X-FTN-PID: Synchronet 3.20a-Linux master/02a3031aa Jan 30 2023 GCC 9.4.0
X-FTN-CHRS: CP437 2
WhenImported: 20230130234653-0800 41e0
WhenExported: 20230131041816-0800 41e0
ExportedFrom: VERT sync-js 3796
WhenImported: 20230131014033-0600 4168
WhenExported: 20230131014652-0600 4168
ExportedFrom: EOTLBBS dove-syncjs 1306
X-Newsreader: Claws Mail 4.1.1git14 (GTK 3.24.20; x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
 by: Nelgin - Tue, 31 Jan 2023 00:40 UTC

On Mon, 23 Jan 2023 00:41:10 -0600
"ansunent" <ansunent@VERT/ANSUN> wrote:

> Hey can anyone check out this script and tell me where it may have
> gone wrong? I keep getting a syntax error on line 17
>
> Line 17: https.get(weatherURL, (res) => {
>
> The purpose of the script is to periodically check weather.gov for
> new or updated severe weather alerts and to post those in my IRC
> room. Below is the whole script. I appreciate any help you can give.
>

Use ircbot, it has a built in weather function.
--
End Of The Line BBS - Plano, TX
telnet endofthelinebbs.com 23
---
� Synchronet � End Of The Line BBS - endofthelinebbs.com

Re: Weather alerts to IRC room

<63D95990.3308.sync_js@bbses.info>

 copy mid

https://www.rocksolidbbs.com/dovenet/article-flat.php?id=859&group=DOVE-Net.Synchronet_Javascript#859

 copy link   Newsgroups: DOVE-Net.Synchronet_Javascript
From: mro@VERT/BBSESINF (MRO)
To: Nelgin
Subject: Re: Weather alerts to IRC room
Message-ID: <63D95990.3308.sync_js@bbses.info>
Date: Tue, 31 Jan 2023 05:10:24 -0600
X-Comment-To: Nelgin
Path: rocksolidbbs.com!not-for-mail
Organization: bbses.info
Newsgroups: DOVE-Net.Synchronet_Javascript
In-Reply-To: <20230131014033.1fc8e9bc@wibble.sysadmininc.com>
References: <20230131014033.1fc8e9bc@wibble.sysadmininc.com>
X-FTN-PID: Synchronet 3.19b-Win32 master/a2a9dc027 Jan 2 2022 MSC 1928
X-FTN-CHRS: CP437 2
WhenImported: 20230131101749-0800 41e0
WhenExported: 20230131101815-0800 41e0
ExportedFrom: VERT sync-js 3797
WhenImported: 20230131121024-0600 4168
WhenExported: 20230131121747-0600 4168
ExportedFrom: BBSESINF sync_js 3308
Content-Type: text/plain; charset=IBM437
Content-Transfer-Encoding: 8bit
 by: MRO - Tue, 31 Jan 2023 11:10 UTC

Re: Re: Weather alerts to IRC room
By: Nelgin to ansunent on Tue Jan 31 2023 01:40 am

>
>
> Use ircbot, it has a built in weather function.

yeah where's the docs for it? i tried setting it up before and couldn't get it to work and there were no error msgs.
---
■ Synchronet ■ ::: BBSES.info - free BBS services :::

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor