Compare commits
2 commits
main
...
dziban303-
Author | SHA1 | Date | |
---|---|---|---|
|
310daf37f9 | ||
|
d2df2a48ba |
|
@ -365,7 +365,7 @@
|
||||||
},
|
},
|
||||||
"FFW": {
|
"FFW": {
|
||||||
"text": "Flash Flood Warning",
|
"text": "Flash Flood Warning",
|
||||||
"priority": 5
|
"priority": 4
|
||||||
},
|
},
|
||||||
"FLN": {
|
"FLN": {
|
||||||
"priority": 1,
|
"priority": 1,
|
||||||
|
@ -1164,7 +1164,7 @@
|
||||||
"text": "Tropical Cyclone Watch/Warning Break Points"
|
"text": "Tropical Cyclone Watch/Warning Break Points"
|
||||||
},
|
},
|
||||||
"TIB": {
|
"TIB": {
|
||||||
"priority": 3,
|
"priority": 4,
|
||||||
"text": "Tsunami Bulletin"
|
"text": "Tsunami Bulletin"
|
||||||
},
|
},
|
||||||
"TID": {
|
"TID": {
|
||||||
|
@ -1308,7 +1308,7 @@
|
||||||
"text": "Routine Space Environment Product Issued Weekly"
|
"text": "Routine Space Environment Product Issued Weekly"
|
||||||
},
|
},
|
||||||
"WOU": {
|
"WOU": {
|
||||||
"priority": 5,
|
"priority": 4,
|
||||||
"text": "Tornado/Severe Thunderstorm Watch"
|
"text": "Tornado/Severe Thunderstorm Watch"
|
||||||
},
|
},
|
||||||
"WS1": {
|
"WS1": {
|
||||||
|
@ -1365,11 +1365,11 @@
|
||||||
},
|
},
|
||||||
"CFA": {
|
"CFA": {
|
||||||
"text": "Coastal Flood Watch",
|
"text": "Coastal Flood Watch",
|
||||||
"priority": 3
|
"priority": 4
|
||||||
},
|
},
|
||||||
"FLA": {
|
"FLA": {
|
||||||
"text": "Flood Watch",
|
"text": "Flood Watch",
|
||||||
"priority": 3
|
"priority": 2
|
||||||
},
|
},
|
||||||
"HWA": {
|
"HWA": {
|
||||||
"text": "High Wind Watch",
|
"text": "High Wind Watch",
|
||||||
|
@ -1389,7 +1389,7 @@
|
||||||
},
|
},
|
||||||
"SVA": {
|
"SVA": {
|
||||||
"text": "Severe Thunderstorm Watch",
|
"text": "Severe Thunderstorm Watch",
|
||||||
"priority": 5
|
"priority": 4
|
||||||
},
|
},
|
||||||
"TOA": {
|
"TOA": {
|
||||||
"text": "Tornado Watch",
|
"text": "Tornado Watch",
|
||||||
|
@ -1405,7 +1405,7 @@
|
||||||
},
|
},
|
||||||
"TSA": {
|
"TSA": {
|
||||||
"text": "Tsunami Watch",
|
"text": "Tsunami Watch",
|
||||||
"priority": 5
|
"priority": 4
|
||||||
},
|
},
|
||||||
"TSW": {
|
"TSW": {
|
||||||
"text": "Tsunami Warning",
|
"text": "Tsunami Warning",
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
{
|
{
|
||||||
"convective": [
|
"convective": [
|
||||||
"https://weather.cod.edu/cdata/text/images/spc/co/day1/categorical/spccoday1.categorical.latest.png",
|
"https://www.spc.noaa.gov/products/outlook/day1otlk.gif",
|
||||||
"https://climate.cod.edu/data/text/images/spc/co/day2/categorical/spccoday2.categorical.latest.png",
|
"https://www.spc.noaa.gov/products/outlook/day2otlk.gif",
|
||||||
"https://climate.cod.edu/data/text/images/spc/co/day3/categorical/spccoday3.categorical.latest.png",
|
"https://www.spc.noaa.gov/products/outlook/day3otlk.gif",
|
||||||
"https://climate.cod.edu/data/text/images/spc/co/day4/severe/spccoday4.severe.latest.png",
|
"https://www.spc.noaa.gov/products/exper/day4-8/day4prob.gif",
|
||||||
"https://climate.cod.edu/data/text/images/spc/co/day5/severe/spccoday5.severe.latest.png",
|
"https://www.spc.noaa.gov/products/exper/day4-8/day5prob.gif",
|
||||||
"https://climate.cod.edu/data/text/images/spc/co/day6/severe/spccoday6.severe.latest.png",
|
"https://www.spc.noaa.gov/products/exper/day4-8/day6prob.gif",
|
||||||
"https://climate.cod.edu/data/text/images/spc/co/day7/severe/spccoday7.severe.latest.png",
|
"https://www.spc.noaa.gov/products/exper/day4-8/day7prob.gif",
|
||||||
"https://climate.cod.edu/data/text/images/spc/co/day8/severe/spccoday8.severe.latest.png"
|
"https://www.spc.noaa.gov/products/exper/day4-8/day8prob.gif"
|
||||||
],
|
],
|
||||||
"fire": [
|
"fire": [
|
||||||
"https://www.spc.noaa.gov/products/exper/fire_wx/imgs/day1otlk_fire.gif",
|
"https://www.spc.noaa.gov/products/exper/fire_wx/imgs/day1otlk_fire.gif",
|
||||||
|
|
|
@ -590,11 +590,5 @@
|
||||||
"fgf": {
|
"fgf": {
|
||||||
"room": "fgfchat",
|
"room": "fgfchat",
|
||||||
"location": "Grand_Forks"
|
"location": "Grand_Forks"
|
||||||
|
|
||||||
},
|
|
||||||
"hawaii": {
|
|
||||||
"room": "hawaii",
|
|
||||||
"location": "Hawaii"
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
33
index.js
33
index.js
|
@ -377,14 +377,13 @@ xmpp.on("stanza", (stanza) => {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
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} - ${evt.text} - ${product_id.timestamp}`);
|
|
||||||
messages++;
|
messages++;
|
||||||
|
|
||||||
|
|
||||||
// Handle NTFY
|
// Handle NTFY
|
||||||
if (config.ntfy.enabled) {
|
if (config.ntfy.enabled) {
|
||||||
//if (config.debug >= 1) console.log(`${colors.magenta("[DEBUG]")} Sending NTFY for ${config.ntfy.prefix}${fromChannel}`)
|
if (config.debug >= 1) console.log(`${colors.magenta("[DEBUG]")} Sending NTFY for ${config.ntfy.prefix}${fromChannel}`)
|
||||||
ntfyBody = {
|
ntfyBody = {
|
||||||
"topic": `${config.ntfy.prefix}${fromChannel}`,
|
"topic": `${config.ntfy.prefix}${fromChannel}`,
|
||||||
"message": bodyData.string,
|
"message": bodyData.string,
|
||||||
|
@ -402,7 +401,7 @@ xmpp.on("stanza", (stanza) => {
|
||||||
'Authorization': `Bearer ${config.ntfy.token}`
|
'Authorization': `Bearer ${config.ntfy.token}`
|
||||||
}
|
}
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
//if (config.debug >= 1) console.log(`${colors.magenta("[DEBUG]")} NTFY sent for ${config.ntfy.prefix}${fromChannel} with status ${res.status} ${res.statusText}`);
|
if (config.debug >= 1) console.log(`${colors.magenta("[DEBUG]")} NTFY sent for ${config.ntfy.prefix}${fromChannel} with status ${res.status} ${res.statusText}`);
|
||||||
if (res.status !== 200) console.log(`${colors.red("[ERROR]")} NTFY failed for ${config.ntfy.prefix}${fromChannel} with status ${res.status} ${res.statusText}`);
|
if (res.status !== 200) console.log(`${colors.red("[ERROR]")} NTFY failed for ${config.ntfy.prefix}${fromChannel} with status ${res.status} ${res.statusText}`);
|
||||||
|
|
||||||
|
|
||||||
|
@ -523,7 +522,6 @@ xmpp.on("stanza", (stanza) => {
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.log(`${colors.red("[ERROR]")} Failed to send message to ${channel.guild.ownerId}`);
|
console.log(`${colors.red("[ERROR]")} Failed to send message to ${channel.guild.ownerId}`);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
if (channel.guildId == config.discord.mainGuild) return;
|
|
||||||
db.run(`DELETE FROM channels WHERE channelid = ? AND iemchannel = ?`, [channel.id, fromChannel], (err) => {
|
db.run(`DELETE FROM channels WHERE channelid = ? AND iemchannel = ?`, [channel.id, fromChannel], (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err.message);
|
console.error(err.message);
|
||||||
|
@ -577,27 +575,6 @@ xmpp.on("stanza", (stanza) => {
|
||||||
thisMsg.content = row.custommessage || null;
|
thisMsg.content = row.custommessage || null;
|
||||||
user.send(thisMsg).catch((err) => {
|
user.send(thisMsg).catch((err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}).catch((err) => {
|
|
||||||
console.log(`${colors.yellow("[WARN]")} Failed to send message to ${user.tag} (${user.id})`);
|
|
||||||
const logChannel = discord.guilds.cache.get(config.discord.mainGuild).channels.cache.get(config.discord.logChannel);
|
|
||||||
logChannel.send({
|
|
||||||
embeds: [
|
|
||||||
{
|
|
||||||
title: "Failed to send DM",
|
|
||||||
description: `User may have DMs disabled, or bot doesnt' share a server anymore!.
|
|
||||||
User: ${user.tag} (${user.id})
|
|
||||||
Sub Info: \`\`\`json\n${JSON.stringify(row)}\`\`\``,
|
|
||||||
color: 0xff0000
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}).then(() => {
|
|
||||||
db.run(`DELETE FROM userAlerts WHERE userid = ? AND iemchannel = ?`, [user.id, fromChannel], (err) => {
|
|
||||||
if (err) {
|
|
||||||
console.error(err.message);
|
|
||||||
}
|
|
||||||
console.log(`${colors.cyan("[INFO]")} Deleted user ${user.id} from database`);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
|
@ -1590,8 +1567,6 @@ discord.on("guildCreate", async (guild) => {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}).catch((err) => {
|
|
||||||
console.log(`${colors.red("[ERROR]")} Failed to send message to user ${user.id}: ${err.message}`);
|
|
||||||
})
|
})
|
||||||
channel.send({
|
channel.send({
|
||||||
embeds: [
|
embeds: [
|
||||||
|
@ -1670,7 +1645,5 @@ process.on("uncaughtException", (error) => {
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Login to discord
|
// Login to discord
|
||||||
discord.login(config.discord.token);
|
discord.login(config.discord.token);
|
Loading…
Reference in a new issue