Compare commits
4 commits
Author | SHA1 | Date | |
---|---|---|---|
|
0e64a9f0c8 | ||
|
41ec69ab94 | ||
|
e991b42e60 | ||
|
685977f771 |
33
debug.js
Normal file
33
debug.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
const WebSocket = require('ws');
|
||||||
|
|
||||||
|
const wsUrl = 'wss://iem-alerter.ko4wal.radio/iem'; // Replace with actual WebSocket URL
|
||||||
|
|
||||||
|
const ws = new WebSocket(wsUrl, {headers: {
|
||||||
|
'User-Agent': 'iem-debugger/1.0',
|
||||||
|
}});
|
||||||
|
|
||||||
|
ws.on('open', () => {
|
||||||
|
console.log('WebSocket connection opened.');
|
||||||
|
ws.send(JSON.stringify({"type":"subscribe"}));
|
||||||
|
});
|
||||||
|
|
||||||
|
ws.on('message', (data) => {
|
||||||
|
console.log("msg rx")
|
||||||
|
try {
|
||||||
|
const msg = JSON.parse(data);
|
||||||
|
// Assuming the message has 'channel' and 'product_id' fields
|
||||||
|
if (msg.channel && msg.product_data) {
|
||||||
|
console.log(`Channel: ${msg.channel}, Product ID: ${msg.product_data}`);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error parsing message:', err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ws.on('error', (err) => {
|
||||||
|
console.error('WebSocket error:', err);
|
||||||
|
});
|
||||||
|
|
||||||
|
ws.on('close', () => {
|
||||||
|
console.log('WebSocket connection closed.');
|
||||||
|
});
|
4
index.js
4
index.js
|
@ -445,7 +445,7 @@ xmpp.on("stanza", (stanza) => {
|
||||||
// Stops spam from getting old messages
|
// Stops spam from getting old messages
|
||||||
if (startup) return;
|
if (startup) return;
|
||||||
// Get channel name
|
// Get channel name
|
||||||
fromChannel = stanza.attrs.from.split("@")[0];
|
const fromChannel = stanza.attrs.from.split("@")[0];
|
||||||
// Ignores
|
// Ignores
|
||||||
if (!stanza.getChild("x")) return; // No PID, ignore it
|
if (!stanza.getChild("x")) return; // No PID, ignore it
|
||||||
if (!stanza.getChild("x").attrs.product_id) return;
|
if (!stanza.getChild("x").attrs.product_id) return;
|
||||||
|
@ -503,7 +503,7 @@ xmpp.on("stanza", (stanza) => {
|
||||||
const diff = (now - product_id.timestamp) / 1000 / 60;
|
const diff = (now - product_id.timestamp) / 1000 / 60;
|
||||||
if (diff > 3) return;
|
if (diff > 3) return;
|
||||||
// if (config.debug >= 1) console.log(`${colors.magenta("[DEBUG]")} New message from ${fromChannel}`);
|
// if (config.debug >= 1) console.log(`${colors.magenta("[DEBUG]")} New message from ${fromChannel}`);
|
||||||
console.log(`${colors.cyan("[INFO]")} ${getWFOByRoom(fromChannel).location} - ${product_id_raw} - ${evt.text} - ${product_id.timestamp}`);
|
console.log(`${colors.cyan("[INFO]")} ${fromChannel} ${getWFOByRoom(fromChannel).location} - ${product_id_raw} - ${evt.text} - ${product_id.timestamp}`);
|
||||||
messages++;
|
messages++;
|
||||||
textTries = 0;
|
textTries = 0;
|
||||||
tryGetText = () => {
|
tryGetText = () => {
|
||||||
|
|
Loading…
Reference in a new issue