uh
All checks were successful
ptero-push / build (push) Successful in 11s

This commit is contained in:
Christopher Cookman 2024-07-31 20:57:49 -06:00
parent 98673be5c7
commit 70c30420fc

View file

@ -43,8 +43,9 @@ const db = new sqlite3.Database("channels.db", (err) => {
}
console.log(`${colors.cyan("[INFO]")} Connected to the database`);
// Create tables if they dont exist
db.run(`CREATE TABLE IF NOT EXISTS channels (channelid TEXT, iemchannel TEXT, custommessage TEXT, minPriority INTEGER, "filter" TEXT, filterevt TEXT);`);
db.run(`CREATE TABLE IF NOT EXISTS channels (channelid TEXT, iemchannel TEXT, custommessage TEXT, minPriority INTEGER, "filter" TEXT, filterEvt TEXT);`);
db.run(`CREATE TABLE IF NOT EXISTS userAlerts (userid TEXT, iemchannel TEXT, filter TEXT, filterEvt TEXT, minPriority INT, custommessage TEXT);`);
db.run(`ALTER TABLE channels RENAME COLUMN filterevt TO filterEvt;`)
});
@ -423,14 +424,14 @@ xmpp.on("stanza", (stanza) => {
if (!rows) return; // No channels to alert
rows.forEach((row) => {
// Get Filters as arrays
if (!row.filterevt) row.filterevt = "";
if (!row.filterEvt) row.filterEvt = "";
if (!row.filter) row.filter = "";
let filterevt = row.filterevt.toLowerCase().split(",");
let filterEvt = row.filterEvt.toLowerCase().split(",");
let filters = row.filter.toLowerCase().split(",");
if (evt.priority < row.minPriority) return;
// If the event type is not in th filter, ignore it. Make sure filterevt isnt null
if (!filterevt[0]) filterevt = [];
if (!filterevt.includes(evt.code.toLowerCase()) && !filterevt.length == 0) return;
// If the event type is not in th filter, ignore it. Make sure filterEvt isnt null
if (!filterEvt[0]) filterEvt = [];
if (!filterEvt.includes(evt.code.toLowerCase()) && !filterEvt.length == 0) return;
let channel = discord.channels.cache.get(row.channelid);
if (!channel) return console.log(`${colors.red("[ERROR]")} Channel ${row.channelid} not found`);
@ -700,7 +701,7 @@ discord.on('ready', async () => {
await (async () => {
try {
//Global
if (config.debug >= 1) console.log(`${colors.magenta("[DEBUG]")} Registering global commands: ${JSON.stringify(commands, null, 2)}`);
if (config.debug >= 1) console.log(`${colors.magenta("[DEBUG]")} Registering global commands`);
await rest.put(Routes.applicationCommands(discord.user.id), { body: commands })
} catch (error) {
console.error(error);
@ -772,7 +773,7 @@ discord.on("interactionCreate", async (interaction) => {
} 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 });
}
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) {
console.error(err.message);
interaction.reply({ content: "Failed to subscribe to room", ephemeral: true });