Compare commits
3 commits
main
...
debug-10-2
Author | SHA1 | Date | |
---|---|---|---|
|
ac4d7c86e7 | ||
|
60f7c22083 | ||
|
443c82fcd9 |
|
@ -1522,6 +1522,9 @@
|
||||||
"REP": {
|
"REP": {
|
||||||
"text": "RECCO Observations (tropical cyclone)",
|
"text": "RECCO Observations (tropical cyclone)",
|
||||||
"priority": 3
|
"priority": 3
|
||||||
|
},
|
||||||
|
"PIR": {
|
||||||
|
"priority": 0,
|
||||||
|
"_comment": "This is an unknown event type, ignore it for now until we know more info"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
1
funcs.js
1
funcs.js
|
@ -1,4 +1,3 @@
|
||||||
const geolib = require("geolib");
|
|
||||||
// Use OSM API to get coordinates https://nominatim.openstreetmap.org/search?q=search+query&format=json&limit=1
|
// Use OSM API to get coordinates https://nominatim.openstreetmap.org/search?q=search+query&format=json&limit=1
|
||||||
const getCoordinates = async (location) => {
|
const getCoordinates = async (location) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
19
index.js
19
index.js
|
@ -356,6 +356,8 @@ xmpp.on("stanza", (stanza) => {
|
||||||
// get product id from "x" tag
|
// get product id from "x" tag
|
||||||
var evt = events[product_id.pil.substring(0, 3)];
|
var evt = events[product_id.pil.substring(0, 3)];
|
||||||
|
|
||||||
|
if (evt.priority === 0) return; // This is an event that we don't care about
|
||||||
|
|
||||||
if (!evt) {
|
if (!evt) {
|
||||||
evt = { name: "Unknown", priority: 3 }
|
evt = { name: "Unknown", priority: 3 }
|
||||||
console.log(`${colors.red("[ERROR]")} Unknown event type: ${product_id.pil.substring(0, 3)}. Fix me`);
|
console.log(`${colors.red("[ERROR]")} Unknown event type: ${product_id.pil.substring(0, 3)}. Fix me`);
|
||||||
|
@ -453,10 +455,12 @@ xmpp.on("stanza", (stanza) => {
|
||||||
if (!row.filter) row.filter = "";
|
if (!row.filter) row.filter = "";
|
||||||
let filterEvt = row.filterEvt.toLowerCase().split(",");
|
let filterEvt = row.filterEvt.toLowerCase().split(",");
|
||||||
let filters = row.filter.toLowerCase().split(",");
|
let filters = row.filter.toLowerCase().split(",");
|
||||||
|
filterEvt = filterEvt.map(filter => filter.startsWith('!') ? filter.substring(1) : filter);
|
||||||
|
filters = filters.map(filter => filter.startsWith('!') ? filter.substring(1) : filter);
|
||||||
if (evt.priority < row.minPriority) return;
|
if (evt.priority < row.minPriority) return;
|
||||||
// If the event type is not in th filter, ignore it. Make sure filterEvt isnt null
|
// If the event type is not in th filter, ignore it. Make sure filterEvt isnt null
|
||||||
if (!filterEvt[0]) filterEvt = [];
|
if (!filterEvt[0]) filterEvt = [];
|
||||||
if (!filterEvt.includes(evt.code.toLowerCase()) && !filterEvt.length == 0) return;
|
if (filterEvt.some(filter => filter.startsWith('!') ? evt.code.toLowerCase() !== filter.substring(1) : !filter.includes(evt.code.toLowerCase())) && filterEvt.length > 0) return;
|
||||||
|
|
||||||
let channel = discord.channels.cache.get(row.channelid);
|
let channel = discord.channels.cache.get(row.channelid);
|
||||||
if (!channel) return console.log(`${colors.red("[ERROR]")} Channel ${row.channelid} not found`);
|
if (!channel) return console.log(`${colors.red("[ERROR]")} Channel ${row.channelid} not found`);
|
||||||
|
@ -499,12 +503,15 @@ xmpp.on("stanza", (stanza) => {
|
||||||
if (!row.filter) row.filter = "";
|
if (!row.filter) row.filter = "";
|
||||||
let filterEvt = row.filterEvt.toLowerCase().split(",");
|
let filterEvt = row.filterEvt.toLowerCase().split(",");
|
||||||
let filters = row.filter.toLowerCase().split(",");
|
let filters = row.filter.toLowerCase().split(",");
|
||||||
|
filterEvt = filterEvt.map(filter => filter.startsWith('!') ? filter.substring(1) : filter);
|
||||||
|
filters = filters.map(filter => filter.startsWith('!') ? filter.substring(1) : filter);
|
||||||
|
|
||||||
|
|
||||||
// If priority is less than the min priority, ignore it
|
// If priority is less than the min priority, ignore it
|
||||||
if (evt.priority < row.minPriority) return;
|
if (evt.priority < row.minPriority) return;
|
||||||
// If the event type is not in th filter, ignore it. Make sure filterEvt isnt null
|
// If the event type is not in th filter, ignore it. Make sure filterEvt isnt null
|
||||||
if (!filterEvt[0]) filterEvt = [];
|
if (!filterEvt[0]) filterEvt = [];
|
||||||
if (!filterEvt.includes(evt.code.toLowerCase()) && !filterEvt.length == 0) return;
|
if (filterEvt.some(filter => filter.startsWith('!') ? evt.code.toLowerCase() === filter.substring(1) : !filter.includes(evt.code.toLowerCase())) && filterEvt.length > 0) return;
|
||||||
let user = discord.users.cache.get(row.userid);
|
let user = discord.users.cache.get(row.userid);
|
||||||
if (!user) return console.log(`${colors.red("[ERROR]")} User ${row.userid} not found`);
|
if (!user) return console.log(`${colors.red("[ERROR]")} User ${row.userid} not found`);
|
||||||
|
|
||||||
|
@ -789,9 +796,9 @@ discord.on("interactionCreate", async (interaction) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err.message);
|
console.error(err.message);
|
||||||
interaction.reply({ content: "Failed to subscribe to room", ephemeral: true });
|
interaction.reply({ content: "Failed to subscribe to room", ephemeral: true });
|
||||||
} else if (row) {
|
} /*else if (row) {
|
||||||
return interaction.reply({ content: `Already subscribed to \`${getWFOByRoom(room).location}\`\nIf you want to update a subscribtion, please unsubscribe and resubscribe. This will be made a command eventually.`, ephemeral: true });
|
return interaction.reply({ content: `Already subscribed to \`${getWFOByRoom(room).location}\`\nIf you want to update a subscribtion, please unsubscribe and resubscribe. This will be made a command eventually.`, ephemeral: true });
|
||||||
}
|
}*/
|
||||||
db.run(`INSERT INTO channels (channelid, iemchannel, custommessage, filter, filterEvt, minPriority) VALUES (?, ?, ?, ? ,? ,?)`, [interaction.channel.id, room, message, filter, filterEvt, minPriority], (err) => {
|
db.run(`INSERT INTO channels (channelid, iemchannel, custommessage, filter, filterEvt, minPriority) VALUES (?, ?, ?, ? ,? ,?)`, [interaction.channel.id, room, message, filter, filterEvt, minPriority], (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err.message);
|
console.error(err.message);
|
||||||
|
@ -806,9 +813,9 @@ discord.on("interactionCreate", async (interaction) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err.message);
|
console.error(err.message);
|
||||||
interaction.reply({ content: "Failed to subscribe to room", ephemeral: true });
|
interaction.reply({ content: "Failed to subscribe to room", ephemeral: true });
|
||||||
} else if (row) {
|
} /*else if (row) {
|
||||||
return interaction.reply({ content: `Already subscribed to \`${getWFOByRoom(room).location}\`\nIf you want to update a subscribtion, please unsubscribe and resubscribe. This will be made a command eventually.`, ephemeral: true });
|
return interaction.reply({ content: `Already subscribed to \`${getWFOByRoom(room).location}\`\nIf you want to update a subscribtion, please unsubscribe and resubscribe. This will be made a command eventually.`, ephemeral: true });
|
||||||
}
|
}*/
|
||||||
db.run(`INSERT INTO userAlerts (userid, iemchannel, custommessage, filter, filterEvt, minPriority) VALUES (?, ?, ?, ? ,?, ?)`, [interaction.user.id, room, message, filter, filterEvt, minPriority], (err) => {
|
db.run(`INSERT INTO userAlerts (userid, iemchannel, custommessage, filter, filterEvt, minPriority) VALUES (?, ?, ?, ? ,?, ?)`, [interaction.user.id, room, message, filter, filterEvt, minPriority], (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err.message);
|
console.error(err.message);
|
||||||
|
|
Loading…
Reference in a new issue