Compare commits

...

19 commits

Author SHA1 Message Date
dziban303 d2df2a48ba Update data/satellites.json 2025-01-18 07:24:04 -07:00
Christopher Cookman bd275403e9 Add discord message when unknown event type trips 2025-01-13 14:36:08 -07:00
Christopher Cookman 9b80f79436 Add Pilot Reports to events 2025-01-13 14:35:07 -07:00
Christopher Cookman 4bb679cef8 Add perm check to subscribe command 2025-01-13 14:24:01 -07:00
Christopher Cookman e952ec60e7 Notify guild owners and remove subs 2025-01-12 23:36:26 -07:00
Christopher Cookman 0227979176 Add full sub info to permission errors 2025-01-12 03:18:24 -07:00
Christopher Cookman 9f31d18a6f Smol fix 2025-01-12 03:06:31 -07:00
Christopher Cookman d491fda5c8 Im dumb 2025-01-12 03:04:56 -07:00
Christopher Cookman 96912d325a Make embed smaller 2025-01-12 03:04:09 -07:00
Christopher Cookman 00f97fd6e6 Damn, busy night lol 2025-01-12 03:02:13 -07:00
Christopher Cookman 09f3fc957c Fix issue 2025-01-12 03:01:17 -07:00
Christopher Cookman cbb1842100 Add message to log channel about failed sends 2025-01-12 03:00:31 -07:00
Christopher Cookman f763a95472 bwuuuuh 2025-01-12 02:54:21 -07:00
Christopher Cookman d88188182c Bwuh 2025-01-12 02:52:16 -07:00
Christopher Cookman 8b94e7e3f8 Possibly notify of bad perms? 2025-01-12 02:50:54 -07:00
Christopher Cookman d653bc3e90 Add discord error logs 2025-01-12 02:41:40 -07:00
Christopher Cookman b5bf06a38d Fix that 2025-01-12 02:36:44 -07:00
Christopher Cookman ae63a0d52d Add .catch to sending discord messages. Hopefully this will fix the log flooding lol 2025-01-12 02:31:17 -07:00
MoSiren 73e42e2288 Updated WSW. 2024-11-21 17:26:34 -07:00
4 changed files with 79 additions and 16 deletions

View file

@ -91,6 +91,4 @@
"zsechat@conference.weather.im",
"zdcchat@conference.weather.im",
"znychat@conference.weather.im"
]

View file

@ -1345,7 +1345,7 @@
},
"WSW": {
"text": "Winter Storm Warning",
"priority": 5
"priority": 4
},
"WWA": {
"priority": 1,
@ -1522,6 +1522,9 @@
"REP": {
"text": "RECCO Observations (tropical cyclone)",
"priority": 3
},
"PIR": {
"text": "Pilot Reports",
"priority": 1
}
}

View file

@ -21,6 +21,7 @@ satMessages = {};
// Setup Discord
const discord = new Discord.Client({
intents: [
"Guilds",
"GuildVoiceStates",
@ -35,7 +36,6 @@ const rest = new REST({
version: '10'
}).setToken(config.discord.token);
// Setup SQlite DB
const db = new sqlite3.Database("channels.db", (err) => {
if (err) {
@ -360,6 +360,16 @@ xmpp.on("stanza", (stanza) => {
evt = { name: "Unknown", priority: 3 }
console.log(`${colors.red("[ERROR]")} Unknown event type: ${product_id.pil.substring(0, 3)}. Fix me`);
console.log(`${colors.magenta("[DEBUG]")} ${bodyData.string}`)
const logChannel = discord.guilds.cache.get(config.discord.mainGuild).channels.cache.get(config.discord.logChannel);
logChannel.send({
embeds: [
{
title: "Unknown Event Type",
description: `Unknown event type: ${product_id.pil.substring(0, 3)}. Please check the logs for more details.`,
color: 0xff0000
}
]
});
}
evt.code = product_id.pil.substring(0, 3);
@ -447,7 +457,7 @@ xmpp.on("stanza", (stanza) => {
console.log(`${colors.red("[ERROR]")} ${err.message}`);
}
if (!rows) return; // No channels to alert
rows.forEach((row) => {
rows.forEach(async (row) => {
// Get Filters as arrays
if (!row.filterEvt) row.filterEvt = "";
if (!row.filter) row.filter = "";
@ -473,6 +483,53 @@ xmpp.on("stanza", (stanza) => {
console.error(err);
}).then((msg) => {
if (msg.channel.type === Discord.ChannelType.GuildAnnouncement) msg.crosspost();
}).catch((err) => {
console.log(`${colors.yellow("[WARN]")} Failed to send message to ${channel.guild.name}/${channel.name} (${channel.guild.id}/${channel.id})`);
const logChannel = discord.guilds.cache.get(config.discord.mainGuild).channels.cache.get(config.discord.logChannel);
logChannel.send({
embeds: [
{
title: "Failed to send message",
description: `There is likely an issue with permissions. Please notify the server owner if possible.
Guild: ${channel.guild.name} (${channel.guild.id})
Channel: ${channel.name} (${channel.id})
Guild Owner: <@${channel.guild.ownerId}> (${channel.guild.ownerId})
Sub Info: \`\`\`json\n${JSON.stringify(row)}\`\`\``,
color: 0xff0000
}
]
});
discord.users.fetch(channel.guild.ownerId).then((user) => {
user.send({
embeds: [
{
title: "Issue with your subscribed channel.",
description: `There is likely an issue with permissions. Please check that I can send messages in <#${channel.id}>\nYour subscription has been removed, and you will need to resubscribe to get alerts.`,
color: 0xff0000,
fields: [
{
name: "Guild",
value: `${channel.guild.name} (${channel.guild.id})`
},
{
name: "Channel",
value: `${channel.name} (${channel.id})`
}
]
}
]
}).catch((err) => {
console.log(`${colors.red("[ERROR]")} Failed to send message to ${channel.guild.ownerId}`);
}).then(() => {
db.run(`DELETE FROM channels WHERE channelid = ? AND iemchannel = ?`, [channel.id, fromChannel], (err) => {
if (err) {
console.error(err.message);
}
console.log(`${colors.cyan("[INFO]")} Deleted channel ${channel.id} from database`);
});
})
});
});
});
}).catch((err) => {
@ -785,6 +842,8 @@ discord.on("interactionCreate", async (interaction) => {
filterEvt = interaction.options.getString("filterevt") || null;
message = interaction.options.getString("message") || null;
if (interaction.inGuild()) {
interaction.channel.send("Permission check").then((msg) => {
msg.delete();
db.get(`SELECT * FROM channels WHERE channelid = ? AND iemchannel = ?`, [interaction.channel.id, room], (err, row) => {
if (err) {
console.error(err.message);
@ -801,6 +860,9 @@ discord.on("interactionCreate", async (interaction) => {
}
});
});
}).catch((err) => {
interaction.reply({ content: "Failed to subscribe to room. Bot does not have send message permissions here!", ephemeral: true });
});
} else { // We're in a DM
db.get(`SELECT * FROM userAlerts WHERE userid = ? AND iemchannel = ?`, [interaction.user.id, room], (err, row) => {
if (err) {