• Weather alerts to IRC room

    From ansunent@VERT/ANSUN to all on Mon Jan 23 00:41:10 2023
    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
  • From Digital Man@VERT to ansunent on Mon Jan 23 09:22:17 2023
    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ã
  • From ansunent@VERT/ANSUN to Digital Man on Mon Jan 23 18:56:18 2023
    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
  • From Digital Man@VERT to ansunent on Mon Jan 23 20:32:00 2023
    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ã
  • From ansunent@VERT/ANSUN to Digital Man on Tue Jan 24 00:31:30 2023
    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
  • From echicken@VERT/ECBBS to ansunent on Thu Jan 26 19:58:08 2023
    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ã
  • From Nelgin@VERT/EOTLBBS to ansunent on Tue Jan 31 01:40:33 2023
    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ã
  • From MRO@VERT/BBSESINF to Nelgin on Tue Jan 31 12:10:24 2023
    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 :::ã