Subj : Weather alerts to IRC room
To   : all
From : ansunent
Date : 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 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