Skip to content
Snippets Groups Projects
Commit f99fc55f authored by echicken's avatar echicken :chicken:
Browse files

Alert message formatting change; handle null from f.readln

parent 5c31c830
No related branches found
No related tags found
No related merge requests found
......@@ -20101,10 +20101,10 @@
var alert = _step28.value;
if (alert.end < js.global.time())
continue;
ws += "Weather alert from:\r\n".concat(alert.sender_name);
ws += "\r\n".concat(alert.event);
ws += "Weather alert from ".concat(alert.sender_name);
ws += "\r\nEvent: ".concat(alert.event);
ws += "\r\nStart: ".concat(js.global.strftime("%Y-%m-%d %H:%M:%S", alert.start), "\r\nEnd: ").concat(js.global.strftime("%Y-%m-%d %H:%M:%S", alert.end));
ws += "\r\n".concat(alert.description);
ws += "\r\n\r\n".concat(alert.description);
}
} catch (err) {
_iterator28.e(err);
......@@ -20130,10 +20130,13 @@
if (!f.open("r"))
throw new Error("Failed to open ".concat(fn, " for reading"));
while (!f.eof) {
var l = f.readln().split(",");
if (parseInt(l[1], 10) !== this.device.configId)
var l = f.readln();
if (l === null)
continue;
if (l[2] !== wah)
var r = l.split(",");
if (parseInt(r[1], 10) !== this.device.configId)
continue;
if (r[2] !== wah)
continue;
ret = false;
break;
......
......@@ -74,10 +74,10 @@ export default class Weather extends Module {
let ws: string = '';
for (const alert of data.alerts) {
if (alert.end < js.global.time()) continue;
ws += `Weather alert from:\r\n${alert.sender_name}`;
ws += `\r\n${alert.event}`;
ws += `Weather alert from ${alert.sender_name}`;
ws += `\r\nEvent: ${alert.event}`;
ws += `\r\nStart: ${js.global.strftime('%Y-%m-%d %H:%M:%S', alert.start)}\r\nEnd: ${js.global.strftime('%Y-%m-%d %H:%M:%S', alert.end)}`;
ws += `\r\n${alert.description}`;
ws += `\r\n\r\n${alert.description}`;
}
return ws === '' ? undefined : ws;
......@@ -96,9 +96,11 @@ export default class Weather extends Module {
} else {
if (!f.open('r')) throw new Error(`Failed to open ${fn} for reading`);
while (!f.eof) {
const l = f.readln().split(',');
if (parseInt(l[1], 10) !== this.device.configId) continue;
if (l[2] !== wah) continue;
const l = f.readln();
if (l === null) continue;
const r = l.split(',');
if (parseInt(r[1], 10) !== this.device.configId) continue;
if (r[2] !== wah) continue;
ret = false;
break;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment